Package org.deeplearning4j.nn.params
Class DefaultParamInitializer
- java.lang.Object
-
- org.deeplearning4j.nn.params.DefaultParamInitializer
-
- All Implemented Interfaces:
ParamInitializer
- Direct Known Subclasses:
CenterLossParamInitializer,ElementWiseParamInitializer,EmbeddingLayerParamInitializer,OCNNParamInitializer,PretrainParamInitializer,VariationalAutoencoderParamInitializer
public class DefaultParamInitializer extends Object implements ParamInitializer
-
-
Constructor Summary
Constructors Constructor Description DefaultParamInitializer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>biasKeys(Layer layer)Bias parameter keys given the layer configurationprotected INDArraycreateBias(long nOut, double biasInit, INDArray biasParamView, boolean initializeParameters)protected INDArraycreateBias(NeuralNetConfiguration conf, INDArray biasParamView, boolean initializeParameters)protected INDArraycreateGain(long nOut, double gainInit, INDArray gainParamView, boolean initializeParameters)protected INDArraycreateGain(NeuralNetConfiguration conf, INDArray gainParamView, boolean initializeParameters)protected INDArraycreateWeightMatrix(long nIn, long nOut, IWeightInit weightInit, INDArray weightParamView, boolean initializeParameters)protected INDArraycreateWeightMatrix(NeuralNetConfiguration conf, INDArray weightParamView, boolean initializeParameters)Map<String,INDArray>getGradientsFromFlattened(NeuralNetConfiguration conf, INDArray gradientView)Return a map of gradients (in their standard non-flattened representation), taken from the flattened (row vector) gradientView array.static DefaultParamInitializergetInstance()protected booleanhasBias(Layer layer)protected booleanhasLayerNorm(Layer layer)Map<String,INDArray>init(NeuralNetConfiguration conf, INDArray paramsView, boolean initializeParams)Initialize the parametersbooleanisBiasParam(Layer layer, String key)Is the specified parameter a bias?booleanisWeightParam(Layer layer, String key)Is the specified parameter a weight?longnumParams(Layer l)longnumParams(NeuralNetConfiguration conf)List<String>paramKeys(Layer layer)Get a list of all parameter keys given the layer configurationList<String>weightKeys(Layer layer)Weight parameter keys given the layer configuration
-
-
-
Field Detail
-
WEIGHT_KEY
public static final String WEIGHT_KEY
- See Also:
- Constant Field Values
-
BIAS_KEY
public static final String BIAS_KEY
- See Also:
- Constant Field Values
-
GAIN_KEY
public static final String GAIN_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static DefaultParamInitializer getInstance()
-
numParams
public long numParams(NeuralNetConfiguration conf)
- Specified by:
numParamsin interfaceParamInitializer
-
numParams
public long numParams(Layer l)
- Specified by:
numParamsin interfaceParamInitializer
-
paramKeys
public List<String> paramKeys(Layer layer)
Description copied from interface:ParamInitializerGet a list of all parameter keys given the layer configuration- Specified by:
paramKeysin interfaceParamInitializer- Parameters:
layer- Layer- Returns:
- All parameter keys
-
weightKeys
public List<String> weightKeys(Layer layer)
Description copied from interface:ParamInitializerWeight parameter keys given the layer configuration- Specified by:
weightKeysin interfaceParamInitializer- Parameters:
layer- Layer- Returns:
- Weight parameter keys
-
biasKeys
public List<String> biasKeys(Layer layer)
Description copied from interface:ParamInitializerBias parameter keys given the layer configuration- Specified by:
biasKeysin interfaceParamInitializer- Parameters:
layer- Layer- Returns:
- Bias parameter keys
-
isWeightParam
public boolean isWeightParam(Layer layer, String key)
Description copied from interface:ParamInitializerIs the specified parameter a weight?- Specified by:
isWeightParamin interfaceParamInitializer- Parameters:
layer- Layerkey- Key to check- Returns:
- True if parameter is a weight
-
isBiasParam
public boolean isBiasParam(Layer layer, String key)
Description copied from interface:ParamInitializerIs the specified parameter a bias?- Specified by:
isBiasParamin interfaceParamInitializer- Parameters:
layer- Layerkey- Key to check- Returns:
- True if parameter is a bias
-
init
public Map<String,INDArray> init(NeuralNetConfiguration conf, INDArray paramsView, boolean initializeParams)
Description copied from interface:ParamInitializerInitialize the parameters- Specified by:
initin interfaceParamInitializer- Parameters:
conf- the configurationparamsView- a view of the full network (backprop) parametersinitializeParams- if true: initialize the parameters according to the configuration. If false: don't modify the values in the paramsView array (but do select out the appropriate subset, reshape etc as required)- Returns:
- Map of parameters keyed by type (view of the 'paramsView' array)
-
getGradientsFromFlattened
public Map<String,INDArray> getGradientsFromFlattened(NeuralNetConfiguration conf, INDArray gradientView)
Description copied from interface:ParamInitializerReturn a map of gradients (in their standard non-flattened representation), taken from the flattened (row vector) gradientView array. The idea is that operates in exactly the same way as the paramsView does in#init(Map, NeuralNetConfiguration, INDArray); thus the position in the view (and, the array orders) must match those of the parameters- Specified by:
getGradientsFromFlattenedin interfaceParamInitializer- Parameters:
conf- ConfigurationgradientView- The flattened gradients array, as a view of the larger array- Returns:
- A map containing an array by parameter type, that is a view of the full network gradients array
-
createBias
protected INDArray createBias(NeuralNetConfiguration conf, INDArray biasParamView, boolean initializeParameters)
-
createBias
protected INDArray createBias(long nOut, double biasInit, INDArray biasParamView, boolean initializeParameters)
-
createGain
protected INDArray createGain(NeuralNetConfiguration conf, INDArray gainParamView, boolean initializeParameters)
-
createGain
protected INDArray createGain(long nOut, double gainInit, INDArray gainParamView, boolean initializeParameters)
-
createWeightMatrix
protected INDArray createWeightMatrix(NeuralNetConfiguration conf, INDArray weightParamView, boolean initializeParameters)
-
createWeightMatrix
protected INDArray createWeightMatrix(long nIn, long nOut, IWeightInit weightInit, INDArray weightParamView, boolean initializeParameters)
-
hasBias
protected boolean hasBias(Layer layer)
-
hasLayerNorm
protected boolean hasLayerNorm(Layer layer)
-
-