# Loss function > During training or testing, a mathematical function that calculates the loss on a batch of examples. A loss function returns a lower loss for models that makes good predictions than for models that make bad predictions.[^1] During [training](https://wiki.g15e.com/pages/Training%20(machine%20learning.txt)) or testing, a mathematical function that calculates the loss on a [batch](https://wiki.g15e.com/pages/Batch%20(machine%20learning.txt)) of [examples](https://wiki.g15e.com/pages/Example%20(machine%20learning.txt)). A loss function returns a lower loss for models that makes good predictions than for models that make bad predictions.[^1] The goal of training is typically to minimize the loss that a loss function returns.[^1] Many different kinds of loss functions exist. Pick the appropriate loss function for the kind of model you are building. For example:[^1] - [L2 loss](https://wiki.g15e.com/pages/L2%20loss.txt) (or [MSE](https://wiki.g15e.com/pages/Mean%20squared%20error.txt)) is the loss function for [linear regression](https://wiki.g15e.com/pages/Linear%20regression.txt). - [Log loss](https://wiki.g15e.com/pages/Log%20loss.txt) is the loss function for [logistic regression](https://wiki.g15e.com/pages/Logistic%20regression.txt). ## Footnotes [^1]: https://developers.google.com/machine-learning/glossary#loss-function