13.3. Mean Squared Error (MSE)

class fhez.nn.loss.mse.MSE

Loss function to node wrapper.

backward(gradient)

Calculate MSE gradient with respect to \(\hat{y}\).

This will take a single gradient value, and return the average gradient with respect to \(\hat{y}\). If \(\hat{y}\) is more than 1 dim it will return a multidimensional array of values which are the average gradients in those dims.

\(\frac{d}{d\hat{y}}(\text{MSE})=\sum_{i=0}^{N-1} -2(y-\hat{y})\)

property cost

Get computational cost of the forward function.

forward(signal=None, y: Optional[numpy.ndarray] = None, y_hat: Optional[numpy.ndarray] = None)

Calculate the loss of the output given the ground truth.

This will take multiple values for both \(y\) and \(\hat{y}\), and return a single value that is the mean of their absolute difference.

\(\text{MSE}=\frac{\sum_{i=0}^{N-1} (y-\hat{y})^2 }{N}\)

update()

Do nothing as there are no parameters to update.

updates()

Do nothing as there are no parameters to update.