Artificial intelligence • Original RRTutors lesson
Gradient Descent, Loss Functions, and Backpropagation
Learn how neural-network parameters are updated to reduce a differentiable training objective.
Concept and explanation
A loss function measures mismatch between predictions and training targets. Gradient descent adjusts parameters in the direction that locally reduces loss; backpropagation efficiently computes derivatives through the network using the chain rule. Learning rate, batch size, initialization, and data order affect optimization and reproducibility.
How to apply it
Track training and validation loss, inspect gradients for instability, and use an optimizer appropriate to the model and task.
Worked example
For regression, mean squared error penalizes large residuals more strongly than mean absolute error.
Illustrative Python example
optimizer.zero_grad()
predictions = model(batch_features)
loss = loss_function(predictions, batch_targets)
loss.backward()
optimizer.step()
Expected result
The sequence clears old gradients, computes loss, backpropagates, and updates parameters.
Limitations and cautions
A lower training loss does not guarantee better generalization or a meaningful objective.
Practice exercise
Explain what might happen when the learning rate is far too high or far too low.
Key takeaway: Optimization minimizes a chosen loss; choosing and validating that loss is a modeling decision.