Class BaseLayer.Builder<T extends BaseLayer.Builder<T>>
- java.lang.Object
-
- org.deeplearning4j.nn.conf.layers.Layer.Builder<T>
-
- org.deeplearning4j.nn.conf.layers.BaseLayer.Builder<T>
-
- Direct Known Subclasses:
FeedForwardLayer.Builder
- Enclosing class:
- BaseLayer
public abstract static class BaseLayer.Builder<T extends BaseLayer.Builder<T>> extends Layer.Builder<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected IActivation
activationFn
Set the activation function for the layer.protected double
biasInit
Bias initialization value, for layers with biases.protected IUpdater
biasUpdater
Gradient updater configuration, for the biases only.protected double
gainInit
Gain initialization value, for layers with Layer Normalization.protected GradientNormalization
gradientNormalization
Gradient normalization strategy.protected double
gradientNormalizationThreshold
Threshold for gradient normalization, only used for GradientNormalization.ClipL2PerLayer, GradientNormalization.ClipL2PerParamType, and GradientNormalization.ClipElementWiseAbsoluteValue
Not used otherwise.
L2 threshold for first two types of clipping, or absolute value threshold for last type of clipping.protected IUpdater
iupdater
Gradient updater.protected List<Regularization>
regularization
Regularization for the parameters (excluding biases).protected List<Regularization>
regularizationBias
Regularization for the bias parameters onlyprotected IWeightInit
weightInitFn
Weight initialization scheme to use, for initial weight valuesprotected IWeightNoise
weightNoise
Set the weight noise (such asDropConnect
andWeightNoise
) for this layer-
Fields inherited from class org.deeplearning4j.nn.conf.layers.Layer.Builder
allParamConstraints, biasConstraints, iDropout, layerName, weightConstraints
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description T
activation(Activation activation)
Set the activation function for the layer, from anActivation
enumeration value.T
activation(IActivation activationFunction)
Set the activation function for the layer.T
biasInit(double biasInit)
Bias initialization value, for layers with biases.T
biasUpdater(IUpdater biasUpdater)
Gradient updater configuration, for the biases only.T
dist(Distribution dist)
Deprecated.T
gainInit(double gainInit)
Gain initialization value, for layers with Layer Normalization.T
gradientNormalization(GradientNormalization gradientNormalization)
Gradient normalization strategy.T
gradientNormalizationThreshold(double threshold)
Threshold for gradient normalization, only used for GradientNormalization.ClipL2PerLayer, GradientNormalization.ClipL2PerParamType, and GradientNormalization.ClipElementWiseAbsoluteValue
Not used otherwise.
L2 threshold for first two types of clipping, or absolute value threshold for last type of clipping.T
l1(double l1)
L1 regularization coefficient (weights only).T
l1Bias(double l1Bias)
L1 regularization coefficient for the bias.T
l2(double l2)
L2 regularization coefficient (weights only).T
l2Bias(double l2Bias)
L2 regularization coefficient for the bias.BaseLayer.Builder
regularization(List<Regularization> regularization)
Set the regularization for the parameters (excluding biases) - for exampleWeightDecay
BaseLayer.Builder
regularizationBias(List<Regularization> regularizationBias)
Set the regularization for the biases only - for exampleWeightDecay
T
updater(Updater updater)
Deprecated.T
updater(IUpdater updater)
Gradient updater.BaseLayer.Builder
weightDecay(double coefficient)
Add weight decay regularization for the network parameters (excluding biases).
This applies weight decay with multiplying the learning rate - seeWeightDecay
for more details.BaseLayer.Builder
weightDecay(double coefficient, boolean applyLR)
Add weight decay regularization for the network parameters (excluding biases).BaseLayer.Builder
weightDecayBias(double coefficient)
Weight decay for the biases only - seeweightDecay(double)
for more details.BaseLayer.Builder
weightDecayBias(double coefficient, boolean applyLR)
Weight decay for the biases only - seeweightDecay(double)
for more detailsT
weightInit(Distribution distribution)
Set weight initialization scheme to random sampling via the specified distribution.T
weightInit(IWeightInit weightInit)
Weight initialization scheme to use, for initial weight valuesT
weightInit(WeightInit weightInit)
Weight initialization scheme to use, for initial weight valuesT
weightNoise(IWeightNoise weightNoise)
Set the weight noise (such asDropConnect
andWeightNoise
) for this layer-
Methods inherited from class org.deeplearning4j.nn.conf.layers.Layer.Builder
build, constrainAllParameters, constrainBias, constrainWeights, dropOut, dropOut, name
-
-
-
-
Field Detail
-
activationFn
protected IActivation activationFn
Set the activation function for the layer. This overload can be used for customIActivation
instances
-
weightInitFn
protected IWeightInit weightInitFn
Weight initialization scheme to use, for initial weight values- See Also:
IWeightInit
-
biasInit
protected double biasInit
Bias initialization value, for layers with biases. Defaults to 0
-
gainInit
protected double gainInit
Gain initialization value, for layers with Layer Normalization. Defaults to 1
-
regularization
protected List<Regularization> regularization
Regularization for the parameters (excluding biases).
-
regularizationBias
protected List<Regularization> regularizationBias
Regularization for the bias parameters only
-
iupdater
protected IUpdater iupdater
-
biasUpdater
protected IUpdater biasUpdater
Gradient updater configuration, for the biases only. If not set, biases will use the updater as set byupdater(IUpdater)
-
gradientNormalization
protected GradientNormalization gradientNormalization
Gradient normalization strategy. Used to specify gradient renormalization, gradient clipping etc.- See Also:
GradientNormalization
-
gradientNormalizationThreshold
protected double gradientNormalizationThreshold
Threshold for gradient normalization, only used for GradientNormalization.ClipL2PerLayer, GradientNormalization.ClipL2PerParamType, and GradientNormalization.ClipElementWiseAbsoluteValue
Not used otherwise.
L2 threshold for first two types of clipping, or absolute value threshold for last type of clipping.
-
weightNoise
protected IWeightNoise weightNoise
Set the weight noise (such asDropConnect
andWeightNoise
) for this layer
-
-
Method Detail
-
activation
public T activation(IActivation activationFunction)
Set the activation function for the layer. This overload can be used for customIActivation
instances- Parameters:
activationFunction
- Activation function to use for the layer
-
activation
public T activation(Activation activation)
Set the activation function for the layer, from anActivation
enumeration value.- Parameters:
activation
- Activation function to use for the layer
-
weightInit
public T weightInit(IWeightInit weightInit)
Weight initialization scheme to use, for initial weight values- See Also:
IWeightInit
-
weightInit
public T weightInit(WeightInit weightInit)
Weight initialization scheme to use, for initial weight values- See Also:
WeightInit
-
weightInit
public T weightInit(Distribution distribution)
Set weight initialization scheme to random sampling via the specified distribution. Equivalent to:.weightInit(new WeightInitDistribution(distribution))
- Parameters:
distribution
- Distribution to use for weight initialization
-
biasInit
public T biasInit(double biasInit)
Bias initialization value, for layers with biases. Defaults to 0- Parameters:
biasInit
- Value to use for initializing biases
-
gainInit
public T gainInit(double gainInit)
Gain initialization value, for layers with Layer Normalization. Defaults to 1- Parameters:
gainInit
- Value to use for initializing gain
-
dist
@Deprecated public T dist(Distribution dist)
Deprecated.Distribution to sample initial weights from. Equivalent to:.weightInit(new WeightInitDistribution(distribution))
-
l1
public T l1(double l1)
L1 regularization coefficient (weights only). Usel1Bias(double)
to configure the l1 regularization coefficient for the bias.
-
l2
public T l2(double l2)
L2 regularization coefficient (weights only). Usel2Bias(double)
to configure the l2 regularization coefficient for the bias.
Note: Generally,WeightDecay
(set viaweightDecay(double,boolean)
should be preferred to L2 regularization. SeeWeightDecay
javadoc for further details.
-
l1Bias
public T l1Bias(double l1Bias)
L1 regularization coefficient for the bias. Default: 0. See alsol1(double)
-
l2Bias
public T l2Bias(double l2Bias)
L2 regularization coefficient for the bias. Default: 0. See alsol2(double)
Note: Generally,WeightDecay
(set viaweightDecayBias(double,boolean)
should be preferred to L2 regularization. SeeWeightDecay
javadoc for further details.
-
weightDecay
public BaseLayer.Builder weightDecay(double coefficient)
Add weight decay regularization for the network parameters (excluding biases).
This applies weight decay with multiplying the learning rate - seeWeightDecay
for more details.- Parameters:
coefficient
- Weight decay regularization coefficient- See Also:
weightDecay(double, boolean)
-
weightDecay
public BaseLayer.Builder weightDecay(double coefficient, boolean applyLR)
Add weight decay regularization for the network parameters (excluding biases). SeeWeightDecay
for more details.- Parameters:
coefficient
- Weight decay regularization coefficientapplyLR
- Whether the learning rate should be multiplied in when performing weight decay updates. SeeWeightDecay
for more details.- See Also:
weightDecay(double, boolean)
-
weightDecayBias
public BaseLayer.Builder weightDecayBias(double coefficient)
Weight decay for the biases only - seeweightDecay(double)
for more details. This applies weight decay with multiplying the learning rate.- Parameters:
coefficient
- Weight decay regularization coefficient- See Also:
weightDecayBias(double, boolean)
-
weightDecayBias
public BaseLayer.Builder weightDecayBias(double coefficient, boolean applyLR)
Weight decay for the biases only - seeweightDecay(double)
for more details- Parameters:
coefficient
- Weight decay regularization coefficient
-
regularization
public BaseLayer.Builder regularization(List<Regularization> regularization)
Set the regularization for the parameters (excluding biases) - for exampleWeightDecay
- Parameters:
regularization
- Regularization to apply for the network parameters/weights (excluding biases)
-
regularizationBias
public BaseLayer.Builder regularizationBias(List<Regularization> regularizationBias)
Set the regularization for the biases only - for exampleWeightDecay
- Parameters:
regularizationBias
- Regularization to apply for the network biases only
-
updater
@Deprecated public T updater(Updater updater)
Deprecated.Gradient updater. For example, SGD for standard stochastic gradient descent, NESTEROV for Nesterov momentum, RSMPROP for RMSProp, etc.- See Also:
Updater
-
biasUpdater
public T biasUpdater(IUpdater biasUpdater)
Gradient updater configuration, for the biases only. If not set, biases will use the updater as set byupdater(IUpdater)
- Parameters:
biasUpdater
- Updater to use for bias parameters
-
gradientNormalization
public T gradientNormalization(GradientNormalization gradientNormalization)
Gradient normalization strategy. Used to specify gradient renormalization, gradient clipping etc.- Parameters:
gradientNormalization
- Type of normalization to use. Defaults to None.- See Also:
GradientNormalization
-
gradientNormalizationThreshold
public T gradientNormalizationThreshold(double threshold)
Threshold for gradient normalization, only used for GradientNormalization.ClipL2PerLayer, GradientNormalization.ClipL2PerParamType, and GradientNormalization.ClipElementWiseAbsoluteValue
Not used otherwise.
L2 threshold for first two types of clipping, or absolute value threshold for last type of clipping.
-
weightNoise
public T weightNoise(IWeightNoise weightNoise)
Set the weight noise (such asDropConnect
andWeightNoise
) for this layer- Parameters:
weightNoise
- Weight noise instance to use
-
-