Implementing Loss Functions
Loss
functions are very important to machine learning algorithms. They measure the distance between the model outputs and the target (truth) values. In this recipe, we show various loss
function implementations in TensorFlow.
Getting ready
In order to optimize our machine learning algorithms, we will need to evaluate the outcomes. Evaluating outcomes in TensorFlow depends on specifying a loss
function. A loss
function tells TensorFlow how good or bad the predictions are compared to the desired result. In most cases, we will have a set of data and a target on which to train our algorithm. The loss
function compares the target to the prediction and gives a numerical distance between the two.
For this recipe, we will cover the main loss
functions that we can implement in TensorFlow.
To see how the different loss
functions operate, we will plot them in this recipe. We will first start a computational graph and load matplotlib
, a python plotting library, as follows:
import...