Lesson 3 of 15
Loss Functions
Measuring Error
A loss function (also called a cost function or objective) measures how wrong our network's predictions are. Training reduces this number. The choice of loss function depends on the task.
Mean Squared Error (Regression)
For regression, we want predictions close to continuous target values:
MSE penalizes large errors quadratically — a prediction off by 2 incurs 4× the loss of one off by 1.
Binary Cross-Entropy (Classification)
For binary classification where is a probability:
This is derived from maximum likelihood. When , only matters — we want . When , only matters — we want .
The clip prevents .
Your Task
Implement:
mse(predictions, targets)— mean squared errorbinary_cross_entropy(predictions, targets)— binary cross-entropy with
Python runtime loading...
Loading...
Click "Run" to execute your code.