public class LossMixtureDensity extends DifferentialFunction 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.
|
dimensions, extraArgs, inPlace, sameDiff, scalarValue| 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.
|
org.nd4j.linalg.primitives.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.
|
List<SDVariable> |
doDiff(List<SDVariable> f1)
The actual implementation for automatic differentiation.
|
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.
|
void |
initFromOnnx(OnnxProto3.NodeProto node,
SameDiff initWith,
Map<String,OnnxProto3.AttributeProto> attributesForNode,
OnnxProto3.GraphProto graph)
Iniitialize the function from the given
OnnxProto3.NodeProto |
void |
initFromTensorFlow(NodeDef nodeDef,
SameDiff initWith,
Map<String,AttrValue> attributesForNode,
GraphDef graph)
Initialize the function from the given
NodeDef |
String |
name()
The opName of this function
|
String |
onnxName()
The opName of this function in onnx
|
String |
opName()
The name of the op
|
Op.Type |
opType()
The type of the op
|
SDVariable[] |
outputVariables()
Return the output variables for this differential function.
|
SDVariable[] |
outputVariables(String baseName)
Return the output functions for this differential function.
|
String |
tensorflowName()
The opName of this function tensorflow
|
String |
toString() |
arg, args, asProperties, attributeAdaptersForFunction, calculateOutputShape, configFieldName, diff, dup, equals, f, getValue, hashCode, hasPlaceHolderInputs, isConfigProperties, larg, mappingsForFunction, onnxNames, opNum, propertiesForFunction, rarg, resolvePropertiesFromSameDiffBeforeExecution, setInstanceId, setValueFor, tensorflowNamespublic LossMixtureDensity.MixtureDensityComponents extractComponents(INDArray output)
public double computeScore(INDArray labels, INDArray preOutput, IActivation activationFn, INDArray mask, boolean average)
computeScore in interface ILossFunctionlabels - 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 ILossFunctionlabels - 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 ILossFunctionlabels - 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 org.nd4j.linalg.primitives.Pair<Double,INDArray> computeGradientAndScore(INDArray labels, INDArray preOutput, IActivation activationFn, INDArray mask, boolean average)
ILossFunctionILossFunction.computeScore(INDArray, INDArray, IActivation, INDArray, boolean)
and ILossFunction.computeGradient(INDArray, INDArray, IActivation, INDArray) individuallycomputeGradientAndScore in interface ILossFunctionlabels - 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 ILossFunctionpublic int getNMixtures()
public int getLabelWidth()
public static LossMixtureDensity.Builder builder()
public SDVariable[] outputVariables()
DifferentialFunctionoutputVariables in class DifferentialFunctionpublic SDVariable[] outputVariables(String baseName)
DifferentialFunctionoutputVariables in class DifferentialFunctionpublic List<SDVariable> doDiff(List<SDVariable> f1)
DifferentialFunctiondoDiff in class DifferentialFunctionpublic String opName()
DifferentialFunctionopName in class DifferentialFunctionpublic Op.Type opType()
DifferentialFunctionopType in class DifferentialFunctionpublic void initFromTensorFlow(NodeDef nodeDef, SameDiff initWith, Map<String,AttrValue> attributesForNode, GraphDef graph)
DifferentialFunctionNodeDefinitFromTensorFlow in class DifferentialFunctionpublic void initFromOnnx(OnnxProto3.NodeProto node, SameDiff initWith, Map<String,OnnxProto3.AttributeProto> attributesForNode, OnnxProto3.GraphProto graph)
DifferentialFunctionOnnxProto3.NodeProtoinitFromOnnx in class DifferentialFunctionpublic String onnxName()
DifferentialFunctiononnxName in class DifferentialFunctionpublic String tensorflowName()
DifferentialFunctiontensorflowName in class DifferentialFunctionCopyright © 2018. All rights reserved.