The primitives every loss function is built from
Most TF math operates element-wise — it applies a scalar function to each element independently. Add, subtract, multiply, divide, square, sqrt, exp, log, sin, sigmoid, tanh, ReLU. These are the atoms loss functions and activations are made of.
Reductions collapse one or more axes. tf.reduce_sum, tf.reduce_mean, tf.reduce_max, tf.reduce_min work globally (returning a scalar) or along a specified axis. The keepdims=True option preserves the reduced dim as size 1, which is essential when broadcasting back to the original shape.
tf.argmax and tf.argmin return the index of the max/min element — used in classification to find the predicted class from logits.
Why this matters: Mean Squared Error is
tf.reduce_mean(tf.square(y_true - y_pred)). Cross-entropy is tf.math.log + tf.reduce_sum. Accuracy is tf.argmax + tf.equal + tf.reduce_mean(tf.cast(...)). Once you see these primitives, you can read any loss function.