This time, our loss function is different. We are using the mean of the squared errors that have pseudocode, which looks something like this:
mse = sum( (actual_y - predicted_y) ^ 2 ) / num_of_y
This can be trivially implemented in Gorgonia as follows:
losses, err := gorgonia.Square(gorgonia.Must(gorgonia.Sub(y, m.out)))
if err != nil {
log.Fatal(err)
}
cost := gorgonia.Must(gorgonia.Mean(losses))