tensornn.loss.MeanSquaredError
- class tensornn.loss.MeanSquaredError
Bases:
LossMean squared error is calculated extremely simply. 1. Find the difference between the prediction vs. the actual results we should have got 2. Square these values, because negatives are the same as positives, only magnitude matters 3. calculate mean
ex: our predictions:
[0.1, 0.2, 0.7], desired:[0, 0, 1]1. pred - actual:[0.1, 0.2, -0.3]2. squared:[0.01, 0.04, 0.09]3. mean:0.04666667Methods
The loss function is used to calculate how off the predictions of the network are.
Used in backpropagation which helps calculates how much each neuron impacts the loss.
source- __repr__()
Return repr(self).
- calculate(pred: Tensor, desired: Tensor) Tensor
The loss function is used to calculate how off the predictions of the network are.
- Parameters:
pred – the prediction of the network
desired – the desired values which the network should have gotten close to
- Returns:
the average of calculated loss for one whole pass of the network
- derivative(pred: Tensor, desired: Tensor) Tensor
Used in backpropagation which helps calculates how much each neuron impacts the loss.
- Parameters:
pred – the prediction of the network
desired – the desired values which the network should have gotten close to
- Returns:
the derivative of the loss function wrt the last layer of the network