public class LossMSE extends LossL2
LossL2
for a mathematically similar loss function (LossL2 does not have division by N, where N is output size)Constructor and Description |
---|
LossMSE() |
LossMSE(INDArray weights)
Mean Squared Error loss function where each the output is (optionally) weighted/scaled by a flags scalar value.
|
Modifier and Type | Method and Description |
---|---|
INDArray |
computeGradient(INDArray labels,
INDArray preOutput,
IActivation activationFn,
INDArray mask)
Compute the gradient of the loss function with respect to the inputs: dL/dOutput
|
double |
computeScore(INDArray labels,
INDArray preOutput,
IActivation activationFn,
INDArray mask,
boolean average)
Compute the score (loss function value) for the given inputs.
|
INDArray |
computeScoreArray(INDArray labels,
INDArray preOutput,
IActivation activationFn,
INDArray mask)
Compute the score (loss function value) for each example individually.
|
String |
name()
The opName of this function
|
String |
toString() |
computeGradientAndScore, scoreArray
public LossMSE()
public LossMSE(INDArray weights)
weights
- Weights array (row vector). May be null.public double computeScore(INDArray labels, INDArray preOutput, IActivation activationFn, INDArray mask, boolean average)
ILossFunction
computeScore
in interface ILossFunction
computeScore
in class LossL2
labels
- Label/expected preOutputpreOutput
- Output of the model (neural network)activationFn
- Activation function that should be applied to preOutputmask
- Mask array; may be nullaverage
- Whether the score should be averaged (divided by number of rows in labels/preOutput) or not @return Loss function valuepublic INDArray computeScoreArray(INDArray labels, INDArray preOutput, IActivation activationFn, INDArray mask)
ILossFunction
computeScoreArray
in interface ILossFunction
computeScoreArray
in class LossL2
labels
- Labels/expected outputpreOutput
- Output of the model (neural network)activationFn
- Activation function that should be applied to preOutputmask
- @return Loss function value for each example; column vectorpublic INDArray computeGradient(INDArray labels, INDArray preOutput, IActivation activationFn, INDArray mask)
ILossFunction
computeGradient
in interface ILossFunction
computeGradient
in class LossL2
labels
- Label/expected outputpreOutput
- Output of the model (neural network), before the activation function is appliedactivationFn
- Activation function that should be applied to preOutputmask
- Mask array; may be nullpublic String name()
name
in interface ILossFunction
name
in class LossL2
Copyright © 2020. All rights reserved.