public class LossMixtureDensity extends Object implements ILossFunction
Modifier and Type | Class and Description |
---|---|
static class |
LossMixtureDensity.Builder |
static class |
LossMixtureDensity.MixtureDensityComponents
This class is a data holder for the mixture density
components for convenient manipulation.
|
Constructor and Description |
---|
LossMixtureDensity() |
Modifier and Type | Method and Description |
---|---|
static LossMixtureDensity.Builder |
builder() |
INDArray |
computeGradient(INDArray labels,
INDArray preOutput,
IActivation activationFn,
INDArray mask)
This method returns the gradient of the cost function with respect to the
output from the previous layer.
|
Pair<Double,INDArray> |
computeGradientAndScore(INDArray labels,
INDArray preOutput,
IActivation activationFn,
INDArray mask,
boolean average)
Compute both the score (loss function value) and gradient.
|
double |
computeScore(INDArray labels,
INDArray preOutput,
IActivation activationFn,
INDArray mask,
boolean average)
Computes the aggregate score as a sum of all of the individual scores of
each of the labels against each of the outputs of the network.
|
INDArray |
computeScoreArray(INDArray labels,
INDArray preOutput,
IActivation activationFn,
INDArray mask)
This method returns the score for each of the given outputs against the
given set of labels.
|
LossMixtureDensity.MixtureDensityComponents |
extractComponents(INDArray output) |
int |
getLabelWidth()
Returns the width of each label vector.
|
int |
getNMixtures()
Returns the number of gaussians this loss function
will attempt to find.
|
String |
name()
The opName of this function
|
String |
toString() |
public LossMixtureDensity.MixtureDensityComponents extractComponents(INDArray output)
public double computeScore(INDArray labels, INDArray preOutput, IActivation activationFn, INDArray mask, boolean average)
computeScore
in interface ILossFunction
labels
- Labels to score against the network.preOutput
- Output of the network (before activation function has been called).activationFn
- Activation function for the network.mask
- Mask to be applied to labels (not used for MDN).average
- Whether or not to return an average instead of a total score (not used).public INDArray computeScoreArray(INDArray labels, INDArray preOutput, IActivation activationFn, INDArray mask)
computeScoreArray
in interface ILossFunction
labels
- Labels give the sample output that the network should
be trying to converge on.preOutput
- The output of the last layer (before applying the activation function).activationFn
- The activation function of the current layer.mask
- Mask to apply to score evaluation (not supported for this cost function).public INDArray computeGradient(INDArray labels, INDArray preOutput, IActivation activationFn, INDArray mask)
computeGradient
in interface ILossFunction
labels
- Labels to train on.preOutput
- Output of neural network before applying the final activation function.activationFn
- Activation function of output layer.mask
- Mask to apply to gradients.public Pair<Double,INDArray> computeGradientAndScore(INDArray labels, INDArray preOutput, IActivation activationFn, INDArray mask, boolean average)
ILossFunction
ILossFunction.computeScore(INDArray, INDArray, IActivation, INDArray, boolean)
and ILossFunction.computeGradient(INDArray, INDArray, IActivation, INDArray)
individuallycomputeGradientAndScore
in interface ILossFunction
labels
- Label/expected outputpreOutput
- 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/output) or notpublic String name()
name
in interface ILossFunction
public int getNMixtures()
public int getLabelWidth()
public static LossMixtureDensity.Builder builder()
Copyright © 2020. All rights reserved.