A loss function measures the discrepancy between a model's predictions and the true target values during training. It provides the optimization signal: gradient descent adjusts weights to minimize this loss. Common loss functions include cross-entropy for classification tasks and mean squared error for regression. Choosing the right loss function is critical — it directly shapes what the model learns to optimize.