Package org.deeplearning4j.nn.conf
Class NeuralNetConfiguration.Builder
- java.lang.Object
-
- org.deeplearning4j.nn.conf.NeuralNetConfiguration.Builder
-
- All Implemented Interfaces:
Cloneable
- Enclosing class:
- NeuralNetConfiguration
public static class NeuralNetConfiguration.Builder extends Object implements Cloneable
NeuralNetConfiguration builder, used as a starting point for creating a MultiLayerConfiguration or ComputationGraphConfiguration.
Note that values set here on the layer will be applied to all relevant layers - unless the value is overridden on a layer's configuration
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Builder()
Builder(NeuralNetConfiguration newConf)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description NeuralNetConfiguration.Builder
activation(Activation activation)
Activation function / neuron non-linearity
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer.NeuralNetConfiguration.Builder
activation(IActivation activationFunction)
Activation function / neuron non-linearity
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer.NeuralNetConfiguration.Builder
biasInit(double biasInit)
Constant for bias initialization.NeuralNetConfiguration.Builder
biasUpdater(IUpdater updater)
Gradient updater configuration, for the biases only.NeuralNetConfiguration
build()
Return a configuration based on this builderNeuralNetConfiguration.Builder
cacheMode(@NonNull CacheMode cacheMode)
This method defines how/if preOutput cache is handled: NONE: cache disabled (default value) HOST: Host memory will be used DEVICE: GPU memory will be used (on CPU backends effect will be the same as for HOST)NeuralNetConfiguration.Builder
clone()
NeuralNetConfiguration.Builder
constrainAllParameters(LayerConstraint... constraints)
Set constraints to be applied to all layers.NeuralNetConfiguration.Builder
constrainBias(LayerConstraint... constraints)
Set constraints to be applied to all layers.NeuralNetConfiguration.Builder
constrainWeights(LayerConstraint... constraints)
Set constraints to be applied to all layers.NeuralNetConfiguration.Builder
convolutionMode(ConvolutionMode convolutionMode)
Sets the convolution mode for convolutional layers, which impacts padding and output sizes.NeuralNetConfiguration.Builder
cudnnAlgoMode(ConvolutionLayer.AlgoMode cudnnAlgoMode)
Sets the cuDNN algo mode for convolutional layers, which impacts performance and memory usage of cuDNN.NeuralNetConfiguration.Builder
dataType(@NonNull DataType dataType)
Set the DataType for the network parameters and activations.NeuralNetConfiguration.Builder
dist(Distribution dist)
Deprecated.NeuralNetConfiguration.Builder
dropOut(double inputRetainProbability)
Dropout probability.NeuralNetConfiguration.Builder
dropOut(IDropout dropout)
Set the dropout for all layers in this network
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer.NeuralNetConfiguration.Builder
gradientNormalization(GradientNormalization gradientNormalization)
Gradient normalization strategy.NeuralNetConfiguration.Builder
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.
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer.ComputationGraphConfiguration.GraphBuilder
graphBuilder()
Create a GraphBuilder (for creating a ComputationGraphConfiguration).NeuralNetConfiguration.Builder
inferenceWorkspaceMode(@NonNull WorkspaceMode workspaceMode)
This method defines Workspace mode being used during inference:
NONE: workspace won't be used
ENABLED: workspaces will be used for inference (reduced memory and better performance)NeuralNetConfiguration.Builder
l1(double l1)
L1 regularization coefficient for the weights (excluding biases).
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer.NeuralNetConfiguration.Builder
l1Bias(double l1Bias)
L1 regularization coefficient for the bias.
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer.NeuralNetConfiguration.Builder
l2(double l2)
L2 regularization coefficient for the weights (excluding biases).
Note: Generally,WeightDecay
(set viaweightDecay(double)
should be preferred to L2 regularization.NeuralNetConfiguration.Builder
l2Bias(double l2Bias)
L2 regularization coefficient for the bias.
Note: Generally,WeightDecay
(set viaweightDecayBias(double,boolean)
should be preferred to L2 regularization.NeuralNetConfiguration.Builder
layer(Layer layer)
Layer class.NeuralNetConfiguration.ListBuilder
list()
Create a ListBuilder (for creating a MultiLayerConfiguration)
Usage:NeuralNetConfiguration.ListBuilder
list(Layer... layers)
Create a ListBuilder (for creating a MultiLayerConfiguration) with the specified layers
Usage:NeuralNetConfiguration.Builder
maxNumLineSearchIterations(int maxNumLineSearchIterations)
Maximum number of line search iterations.NeuralNetConfiguration.Builder
miniBatch(boolean miniBatch)
Process input as minibatch vs full dataset.NeuralNetConfiguration.Builder
minimize(boolean minimize)
Objective function to minimize or maximize cost function Default set to minimize true.NeuralNetConfiguration.Builder
optimizationAlgo(OptimizationAlgorithm optimizationAlgo)
Optimization algorithm to use.NeuralNetConfiguration.Builder
regularization(List<Regularization> regularization)
Set the regularization for the parameters (excluding biases) - for exampleWeightDecay
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer.NeuralNetConfiguration.Builder
regularizationBias(List<Regularization> regularizationBias)
Set the regularization for the biases only - for exampleWeightDecay
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer.NeuralNetConfiguration.Builder
seed(long seed)
Random number generator seed.NeuralNetConfiguration.Builder
stepFunction(StepFunction stepFunction)
Deprecated.NeuralNetConfiguration.Builder
trainingWorkspaceMode(@NonNull WorkspaceMode workspaceMode)
This method defines Workspace mode being used during training:
NONE: workspace won't be used
ENABLED: workspaces will be used for training (reduced memory and better performance)NeuralNetConfiguration.Builder
updater(Updater updater)
Deprecated.NeuralNetConfiguration.Builder
updater(IUpdater updater)
Gradient updater configuration.NeuralNetConfiguration.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.
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer.NeuralNetConfiguration.Builder
weightDecay(double coefficient, boolean applyLR)
Add weight decay regularization for the network parameters (excluding biases).NeuralNetConfiguration.Builder
weightDecayBias(double coefficient)
Weight decay for the biases only - seeweightDecay(double)
for more details.NeuralNetConfiguration.Builder
weightDecayBias(double coefficient, boolean applyLR)
Weight decay for the biases only - seeweightDecay(double)
for more details
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer.NeuralNetConfiguration.Builder
weightInit(Distribution distribution)
Set weight initialization scheme to random sampling via the specified distribution.NeuralNetConfiguration.Builder
weightInit(IWeightInit weightInit)
Weight initialization scheme to use, for initial weight values Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer.NeuralNetConfiguration.Builder
weightInit(WeightInit weightInit)
Weight initialization scheme to use, for initial weight values Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer.NeuralNetConfiguration.Builder
weightNoise(IWeightNoise weightNoise)
Set the weight noise (such asDropConnect
andWeightNoise
) for the layers in this network.
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer.
-
-
-
Field Detail
-
activationFn
protected IActivation activationFn
-
weightInitFn
protected IWeightInit weightInitFn
-
biasInit
protected double biasInit
-
gainInit
protected double gainInit
-
regularization
protected List<Regularization> regularization
-
regularizationBias
protected List<Regularization> regularizationBias
-
idropOut
protected IDropout idropOut
-
weightNoise
protected IWeightNoise weightNoise
-
iUpdater
protected IUpdater iUpdater
-
biasUpdater
protected IUpdater biasUpdater
-
layer
protected Layer layer
-
miniBatch
protected boolean miniBatch
-
maxNumLineSearchIterations
protected int maxNumLineSearchIterations
-
seed
protected long seed
-
optimizationAlgo
protected OptimizationAlgorithm optimizationAlgo
-
stepFunction
protected StepFunction stepFunction
-
minimize
protected boolean minimize
-
gradientNormalization
protected GradientNormalization gradientNormalization
-
gradientNormalizationThreshold
protected double gradientNormalizationThreshold
-
allParamConstraints
protected List<LayerConstraint> allParamConstraints
-
weightConstraints
protected List<LayerConstraint> weightConstraints
-
biasConstraints
protected List<LayerConstraint> biasConstraints
-
trainingWorkspaceMode
protected WorkspaceMode trainingWorkspaceMode
-
inferenceWorkspaceMode
protected WorkspaceMode inferenceWorkspaceMode
-
setTWM
protected boolean setTWM
-
setIWM
protected boolean setIWM
-
cacheMode
protected CacheMode cacheMode
-
dataType
protected DataType dataType
-
convolutionMode
protected ConvolutionMode convolutionMode
-
cudnnAlgoMode
protected ConvolutionLayer.AlgoMode cudnnAlgoMode
-
-
Constructor Detail
-
Builder
public Builder()
-
Builder
public Builder(NeuralNetConfiguration newConf)
-
-
Method Detail
-
miniBatch
public NeuralNetConfiguration.Builder miniBatch(boolean miniBatch)
Process input as minibatch vs full dataset. Default set to true.
-
trainingWorkspaceMode
public NeuralNetConfiguration.Builder trainingWorkspaceMode(@NonNull @NonNull WorkspaceMode workspaceMode)
This method defines Workspace mode being used during training:
NONE: workspace won't be used
ENABLED: workspaces will be used for training (reduced memory and better performance)- Parameters:
workspaceMode
- Workspace mode for training- Returns:
- Builder
-
inferenceWorkspaceMode
public NeuralNetConfiguration.Builder inferenceWorkspaceMode(@NonNull @NonNull WorkspaceMode workspaceMode)
This method defines Workspace mode being used during inference:
NONE: workspace won't be used
ENABLED: workspaces will be used for inference (reduced memory and better performance)- Parameters:
workspaceMode
- Workspace mode for inference- Returns:
- Builder
-
cacheMode
public NeuralNetConfiguration.Builder cacheMode(@NonNull @NonNull CacheMode cacheMode)
This method defines how/if preOutput cache is handled: NONE: cache disabled (default value) HOST: Host memory will be used DEVICE: GPU memory will be used (on CPU backends effect will be the same as for HOST)- Parameters:
cacheMode
- Cache mode to use- Returns:
- Builder
-
minimize
public NeuralNetConfiguration.Builder minimize(boolean minimize)
Objective function to minimize or maximize cost function Default set to minimize true.
-
maxNumLineSearchIterations
public NeuralNetConfiguration.Builder maxNumLineSearchIterations(int maxNumLineSearchIterations)
Maximum number of line search iterations. Only applies for line search optimizers: Line Search SGD, Conjugate Gradient, LBFGS is NOT applicable for standard SGD- Parameters:
maxNumLineSearchIterations
- > 0- Returns:
-
layer
public NeuralNetConfiguration.Builder layer(Layer layer)
Layer class.
-
stepFunction
@Deprecated public NeuralNetConfiguration.Builder stepFunction(StepFunction stepFunction)
Deprecated.Step function to apply for back track line search. Only applies for line search optimizers: Line Search SGD, Conjugate Gradient, LBFGS Options: DefaultStepFunction (default), NegativeDefaultStepFunction GradientStepFunction (for SGD), NegativeGradientStepFunction
-
list
public NeuralNetConfiguration.ListBuilder list()
Create a ListBuilder (for creating a MultiLayerConfiguration)
Usage:
.list() .layer(new DenseLayer.Builder()...build()) ... .layer(new OutputLayer.Builder()...build())
-
list
public NeuralNetConfiguration.ListBuilder list(Layer... layers)
Create a ListBuilder (for creating a MultiLayerConfiguration) with the specified layers
Usage:
.list( new DenseLayer.Builder()...build(), ..., new OutputLayer.Builder()...build())
- Parameters:
layers
- The layer configurations for the network
-
graphBuilder
public ComputationGraphConfiguration.GraphBuilder graphBuilder()
Create a GraphBuilder (for creating a ComputationGraphConfiguration).
-
seed
public NeuralNetConfiguration.Builder seed(long seed)
Random number generator seed. Used for reproducability between runs
-
optimizationAlgo
public NeuralNetConfiguration.Builder optimizationAlgo(OptimizationAlgorithm optimizationAlgo)
Optimization algorithm to use. Most common: OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT- Parameters:
optimizationAlgo
- Optimization algorithm to use when training
-
clone
public NeuralNetConfiguration.Builder clone()
-
activation
public NeuralNetConfiguration.Builder activation(IActivation activationFunction)
Activation function / neuron non-linearity
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- See Also:
activation(Activation)
-
activation
public NeuralNetConfiguration.Builder activation(Activation activation)
Activation function / neuron non-linearity
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.
-
weightInit
public NeuralNetConfiguration.Builder weightInit(IWeightInit weightInit)
Weight initialization scheme to use, for initial weight values Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- See Also:
IWeightInit
-
weightInit
public NeuralNetConfiguration.Builder weightInit(WeightInit weightInit)
Weight initialization scheme to use, for initial weight values Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- See Also:
WeightInit
-
weightInit
public NeuralNetConfiguration.Builder weightInit(Distribution distribution)
Set weight initialization scheme to random sampling via the specified distribution. Equivalent to:.weightInit(new WeightInitDistribution(distribution))
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
distribution
- Distribution to use for weight initialization
-
biasInit
public NeuralNetConfiguration.Builder biasInit(double biasInit)
Constant for bias initialization. Default: 0.0
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
biasInit
- Constant for bias initialization
-
dist
@Deprecated public NeuralNetConfiguration.Builder dist(Distribution dist)
Deprecated.Distribution to sample initial weights from. Equivalent to:.weightInit(new WeightInitDistribution(distribution))
.
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- See Also:
weightInit(Distribution)
-
l1
public NeuralNetConfiguration.Builder l1(double l1)
L1 regularization coefficient for the weights (excluding biases).
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.
-
l2
public NeuralNetConfiguration.Builder l2(double l2)
L2 regularization coefficient for the weights (excluding biases).
Note: Generally,WeightDecay
(set viaweightDecay(double)
should be preferred to L2 regularization. SeeWeightDecay
javadoc for further details.
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.
Note: L2 regularization and weight decay usually should not be used together; if any weight decay (or L2) has been added for the biases, these will be removed first.- See Also:
weightDecay(double, boolean)
-
l1Bias
public NeuralNetConfiguration.Builder l1Bias(double l1Bias)
L1 regularization coefficient for the bias.
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.
-
l2Bias
public NeuralNetConfiguration.Builder l2Bias(double l2Bias)
L2 regularization coefficient for the bias.
Note: Generally,WeightDecay
(set viaweightDecayBias(double,boolean)
should be preferred to L2 regularization. SeeWeightDecay
javadoc for further details.
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.
Note: L2 regularization and weight decay usually should not be used together; if any weight decay (or L2) has been added for the biases, these will be removed first.- See Also:
weightDecayBias(double, boolean)
-
weightDecay
public NeuralNetConfiguration.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.
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
coefficient
- Weight decay regularization coefficient- See Also:
weightDecay(double, boolean)
-
weightDecay
public NeuralNetConfiguration.Builder weightDecay(double coefficient, boolean applyLR)
Add weight decay regularization for the network parameters (excluding biases). SeeWeightDecay
for more details.
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- 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 NeuralNetConfiguration.Builder weightDecayBias(double coefficient)
Weight decay for the biases only - seeweightDecay(double)
for more details. This applies weight decay with multiplying the learning rate.
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
coefficient
- Weight decay regularization coefficient- See Also:
weightDecayBias(double, boolean)
-
weightDecayBias
public NeuralNetConfiguration.Builder weightDecayBias(double coefficient, boolean applyLR)
Weight decay for the biases only - seeweightDecay(double)
for more details
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
coefficient
- Weight decay regularization coefficient
-
regularization
public NeuralNetConfiguration.Builder regularization(List<Regularization> regularization)
Set the regularization for the parameters (excluding biases) - for exampleWeightDecay
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
regularization
- Regularization to apply for the network parameters/weights (excluding biases)
-
regularizationBias
public NeuralNetConfiguration.Builder regularizationBias(List<Regularization> regularizationBias)
Set the regularization for the biases only - for exampleWeightDecay
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
regularizationBias
- Regularization to apply for the network biases only
-
dropOut
public NeuralNetConfiguration.Builder dropOut(double inputRetainProbability)
Dropout probability. This is the probability ofretaining each input activation value for a layer. dropOut(x) will keep an input activation with probability x, and set to 0 with probability 1-x.
dropOut(0.0) is a special value / special case - when set to 0.0., dropout is disabled (not applied). Note that a dropout value of 1.0 is functionally equivalent to no dropout: i.e., 100% probability of retaining each input activation.
Note 1: Dropout is applied at training time only - and is automatically not applied at test time (for evaluation, etc)
Note 2: This sets the probability per-layer. Care should be taken when setting lower values for complex networks (too much information may be lost with aggressive (very low) dropout values).
Note 3: Frequently, dropout is not applied to (or, has higher retain probability for) input (first layer) layers. Dropout is also often not applied to output layers. This needs to be handled MANUALLY by the user - set .dropout(0) on those layers when using global dropout setting.
Note 4: Implementation detail (most users can ignore): DL4J uses inverted dropout, as described here: http://cs231n.github.io/neural-networks-2/
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
inputRetainProbability
- Dropout probability (probability of retaining each input activation value for a layer)- See Also:
dropOut(IDropout)
-
dropOut
public NeuralNetConfiguration.Builder dropOut(IDropout dropout)
Set the dropout for all layers in this network
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
dropout
- Dropout, such asDropout
,GaussianDropout
,GaussianNoise
etc- Returns:
-
weightNoise
public NeuralNetConfiguration.Builder weightNoise(IWeightNoise weightNoise)
Set the weight noise (such asDropConnect
andWeightNoise
) for the layers in this network.
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
weightNoise
- Weight noise instance to use
-
updater
@Deprecated public NeuralNetConfiguration.Builder updater(Updater updater)
Deprecated.
-
updater
public NeuralNetConfiguration.Builder updater(IUpdater updater)
Gradient updater configuration. For example,Adam
orNesterovs
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
updater
- Updater to use
-
biasUpdater
public NeuralNetConfiguration.Builder biasUpdater(IUpdater updater)
Gradient updater configuration, for the biases only. If not set, biases will use the updater as set byupdater(IUpdater)
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
updater
- Updater to use for bias parameters
-
gradientNormalization
public NeuralNetConfiguration.Builder gradientNormalization(GradientNormalization gradientNormalization)
Gradient normalization strategy. Used to specify gradient renormalization, gradient clipping etc. SeeGradientNormalization
for details
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
gradientNormalization
- Type of normalization to use. Defaults to None.- See Also:
GradientNormalization
-
gradientNormalizationThreshold
public NeuralNetConfiguration.Builder 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.
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.
-
convolutionMode
public NeuralNetConfiguration.Builder convolutionMode(ConvolutionMode convolutionMode)
Sets the convolution mode for convolutional layers, which impacts padding and output sizes. SeeConvolutionMode
for details. Defaults to ConvolutionMode.TRUNCATE
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
convolutionMode
- Convolution mode to use
-
cudnnAlgoMode
public NeuralNetConfiguration.Builder cudnnAlgoMode(ConvolutionLayer.AlgoMode cudnnAlgoMode)
Sets the cuDNN algo mode for convolutional layers, which impacts performance and memory usage of cuDNN. SeeConvolutionLayer.AlgoMode
for details. Defaults to "PREFER_FASTEST", but "NO_WORKSPACE" uses less memory.
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
cudnnAlgoMode
- cuDNN algo mode to use
-
constrainAllParameters
public NeuralNetConfiguration.Builder constrainAllParameters(LayerConstraint... constraints)
Set constraints to be applied to all layers. Default: no constraints.
Constraints can be used to enforce certain conditions (non-negativity of parameters, max-norm regularization, etc). These constraints are applied at each iteration, after the parameters have been updated.
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
constraints
- Constraints to apply to all parameters of all layers
-
constrainBias
public NeuralNetConfiguration.Builder constrainBias(LayerConstraint... constraints)
Set constraints to be applied to all layers. Default: no constraints.
Constraints can be used to enforce certain conditions (non-negativity of parameters, max-norm regularization, etc). These constraints are applied at each iteration, after the parameters have been updated.
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
constraints
- Constraints to apply to all bias parameters of all layers
-
constrainWeights
public NeuralNetConfiguration.Builder constrainWeights(LayerConstraint... constraints)
Set constraints to be applied to all layers. Default: no constraints.
Constraints can be used to enforce certain conditions (non-negativity of parameters, max-norm regularization, etc). These constraints are applied at each iteration, after the parameters have been updated.
Note: values set by this method will be applied to all applicable layers in the network, unless a different value is explicitly set on a given layer. In other words: values set via this method are used as the default value, and can be overridden on a per-layer basis.- Parameters:
constraints
- Constraints to apply to all weight parameters of all layers
-
dataType
public NeuralNetConfiguration.Builder dataType(@NonNull @NonNull DataType dataType)
Set the DataType for the network parameters and activations. Must be a floating point type:DataType.DOUBLE
,DataType.FLOAT
orDataType.HALF
.
-
build
public NeuralNetConfiguration build()
Return a configuration based on this builder- Returns:
-
-