Package org.deeplearning4j.nn.gradient
Class DefaultGradient
- java.lang.Object
-
- org.deeplearning4j.nn.gradient.DefaultGradient
-
- All Implemented Interfaces:
Serializable
,Gradient
public class DefaultGradient extends Object implements Gradient
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static char
DEFAULT_FLATTENING_ORDER
-
Constructor Summary
Constructors Constructor Description DefaultGradient()
DefaultGradient(INDArray flattenedGradient)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear residual parameters (useful for returning a gradient and then clearing old objects)Character
flatteningOrderForVariable(String variable)
Return the gradient flattening order for the specified variable, or null if it is not explicitly setINDArray
getGradientFor(String variable)
The gradient for the given variableINDArray
gradient()
The full gradient as one flat vectorINDArray
gradient(List<String> order)
The full gradient as one flat vectorMap<String,INDArray>
gradientForVariable()
Gradient look up tableINDArray
setGradientFor(String variable, INDArray newGradient)
Update gradient for the given variableINDArray
setGradientFor(String variable, INDArray gradient, Character flatteningOrder)
Update gradient for the given variable; also (optionally) specify the order in which the array should be flattened to a row vectorString
toString()
-
-
-
Field Detail
-
DEFAULT_FLATTENING_ORDER
public static final char DEFAULT_FLATTENING_ORDER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultGradient
public DefaultGradient()
-
DefaultGradient
public DefaultGradient(INDArray flattenedGradient)
-
-
Method Detail
-
gradientForVariable
public Map<String,INDArray> gradientForVariable()
Description copied from interface:Gradient
Gradient look up table- Specified by:
gradientForVariable
in interfaceGradient
- Returns:
- the gradient look up table
-
gradient
public INDArray gradient(List<String> order)
Description copied from interface:Gradient
The full gradient as one flat vector
-
gradient
public INDArray gradient()
Description copied from interface:Gradient
The full gradient as one flat vector
-
clear
public void clear()
Description copied from interface:Gradient
Clear residual parameters (useful for returning a gradient and then clearing old objects)
-
getGradientFor
public INDArray getGradientFor(String variable)
Description copied from interface:Gradient
The gradient for the given variable- Specified by:
getGradientFor
in interfaceGradient
- Parameters:
variable
- the variable to get the gradient for- Returns:
- the gradient for the given variable or null
-
setGradientFor
public INDArray setGradientFor(String variable, INDArray newGradient)
Description copied from interface:Gradient
Update gradient for the given variable- Specified by:
setGradientFor
in interfaceGradient
- Parameters:
variable
- the variable to get the gradient fornewGradient
- the gradient values- Returns:
- the gradient for the given variable or null
-
setGradientFor
public INDArray setGradientFor(String variable, INDArray gradient, Character flatteningOrder)
Description copied from interface:Gradient
Update gradient for the given variable; also (optionally) specify the order in which the array should be flattened to a row vector- Specified by:
setGradientFor
in interfaceGradient
- Parameters:
variable
- the variable to get the gradient forgradient
- the gradient valuesflatteningOrder
- the order in which gradients should be flattened (null ok - default)- Returns:
- the gradient for the given variable or null
-
flatteningOrderForVariable
public Character flatteningOrderForVariable(String variable)
Description copied from interface:Gradient
Return the gradient flattening order for the specified variable, or null if it is not explicitly set- Specified by:
flatteningOrderForVariable
in interfaceGradient
- Parameters:
variable
- Variable to return the gradient flattening order for- Returns:
- Order in which the specified variable's gradient should be flattened
-
-