Class MeanSquaredErrorLoss

java.lang.Object
deepnetts.net.loss.MeanSquaredErrorLoss
All Implemented Interfaces:
LossFunction, Serializable

public final class MeanSquaredErrorLoss extends Object implements LossFunction, Serializable
Mean Squared Error Loss function. Sum squared errors over all input patterns and all outputs. Should be used for regression problems. Math formula: N K E = 1/(2*N*K) * SUM(SUM(y-t)^2) + regSum where N is number of patterns and K is dimension of output vector, and regSum is L1 or L2 regularization multiplied with lambda. Bishop, pg. 89, eq. 3.34 Also recommended this formula in Proben1 Technical report
See Also:
  • Constructor Details

    • MeanSquaredErrorLoss

      public MeanSquaredErrorLoss(NeuralNetwork neuralNet)
      Creates a new mean squared error loss for the given neural network.
      Parameters:
      neuralNet -
  • Method Details

    • addPatternError

      public TensorBase addPatternError(TensorBase predictedOut, TensorBase targetOut)
      Adds output error vector for the given predicted and target output vectors to total error sum and returns and error vector.
      Specified by:
      addPatternError in interface LossFunction
      Parameters:
      predictedOut - predicted/actual network output vector
      targetOut - target network output vector
      predictedOutput -
      targetOutput -
      Returns:
    • addRegularizationSum

      public void addRegularizationSum(float regSum)
      Add regularization sum to total loss
      Specified by:
      addRegularizationSum in interface LossFunction
      Parameters:
      regSum - regularization sum
    • getTotal

      public float getTotal()
      Description copied from interface: LossFunction
      Returns the total error calculated by this loss function.
      Specified by:
      getTotal in interface LossFunction
      Returns:
      total error calculated by this loss function
    • reset

      public void reset()
      Description copied from interface: LossFunction
      Resets the total error and pattern counter.
      Specified by:
      reset in interface LossFunction
    • getPatternLoss

      public float getPatternLoss()
      Specified by:
      getPatternLoss in interface LossFunction