public static class NeuralNetConfiguration.Builder extends Object implements Cloneable
Modifier and Type | Field and Description |
---|---|
protected org.nd4j.linalg.activations.IActivation |
activationFn |
protected List<LayerConstraint> |
allParamConstraints |
protected List<LayerConstraint> |
biasConstraints |
protected double |
biasInit |
protected org.nd4j.linalg.learning.config.IUpdater |
biasUpdater |
protected CacheMode |
cacheMode |
protected ConvolutionMode |
convolutionMode |
protected ConvolutionLayer.AlgoMode |
cudnnAlgoMode |
protected Distribution |
dist |
protected GradientNormalization |
gradientNormalization |
protected double |
gradientNormalizationThreshold |
protected IDropout |
idropOut |
protected WorkspaceMode |
inferenceWorkspaceMode |
protected org.nd4j.linalg.learning.config.IUpdater |
iUpdater |
protected double |
l1 |
protected double |
l1Bias |
protected double |
l2 |
protected double |
l2Bias |
protected Layer |
layer |
protected int |
maxNumLineSearchIterations |
protected boolean |
miniBatch |
protected boolean |
minimize |
protected OptimizationAlgorithm |
optimizationAlgo |
protected boolean |
pretrain |
protected long |
seed |
protected boolean |
setIWM |
protected boolean |
setTWM |
protected StepFunction |
stepFunction |
protected WorkspaceMode |
trainingWorkspaceMode |
protected List<LayerConstraint> |
weightConstraints |
protected WeightInit |
weightInit |
protected IWeightNoise |
weightNoise |
Constructor and Description |
---|
Builder() |
Builder(NeuralNetConfiguration newConf) |
Modifier and Type | Method and Description |
---|---|
NeuralNetConfiguration.Builder |
activation(org.nd4j.linalg.activations.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(org.nd4j.linalg.activations.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(org.nd4j.linalg.learning.config.IUpdater updater)
Gradient updater configuration, for the biases only.
|
NeuralNetConfiguration |
build()
Return a configuration based on this builder
|
NeuralNetConfiguration.Builder |
cacheMode(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 |
dist(Distribution dist)
Distribution to sample initial weights from.
|
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(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.
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.
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 |
l2Bias(double l2Bias)
L2 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 |
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 |
seed(long seed)
Random number generator seed.
|
NeuralNetConfiguration.Builder |
stepFunction(StepFunction stepFunction)
Deprecated.
|
NeuralNetConfiguration.Builder |
trainingWorkspaceMode(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(org.nd4j.linalg.learning.config.IUpdater updater)
Gradient updater configuration.
|
NeuralNetConfiguration.Builder |
updater(Updater updater)
Deprecated.
|
NeuralNetConfiguration.Builder |
weightInit(Distribution distribution)
Set weight initialization scheme to random sampling via the specified distribution.
|
NeuralNetConfiguration.Builder |
weightInit(WeightInit weightInit)
Weight initialization scheme.
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 as
DropConnect and
WeightNoise ) 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. |
protected org.nd4j.linalg.activations.IActivation activationFn
protected WeightInit weightInit
protected double biasInit
protected Distribution dist
protected double l1
protected double l2
protected double l1Bias
protected double l2Bias
protected IDropout idropOut
protected IWeightNoise weightNoise
protected org.nd4j.linalg.learning.config.IUpdater iUpdater
protected org.nd4j.linalg.learning.config.IUpdater biasUpdater
protected Layer layer
protected boolean miniBatch
protected int maxNumLineSearchIterations
protected long seed
protected OptimizationAlgorithm optimizationAlgo
protected StepFunction stepFunction
protected boolean minimize
protected GradientNormalization gradientNormalization
protected double gradientNormalizationThreshold
protected boolean pretrain
protected List<LayerConstraint> allParamConstraints
protected List<LayerConstraint> weightConstraints
protected List<LayerConstraint> biasConstraints
protected WorkspaceMode trainingWorkspaceMode
protected WorkspaceMode inferenceWorkspaceMode
protected boolean setTWM
protected boolean setIWM
protected CacheMode cacheMode
protected ConvolutionMode convolutionMode
protected ConvolutionLayer.AlgoMode cudnnAlgoMode
public Builder()
public Builder(NeuralNetConfiguration newConf)
public NeuralNetConfiguration.Builder miniBatch(boolean miniBatch)
public NeuralNetConfiguration.Builder trainingWorkspaceMode(@NonNull WorkspaceMode workspaceMode)
workspaceMode
- Workspace mode for trainingpublic NeuralNetConfiguration.Builder inferenceWorkspaceMode(@NonNull WorkspaceMode workspaceMode)
workspaceMode
- Workspace mode for inferencepublic NeuralNetConfiguration.Builder cacheMode(@NonNull CacheMode cacheMode)
cacheMode
- Cache mode to usepublic NeuralNetConfiguration.Builder minimize(boolean minimize)
public NeuralNetConfiguration.Builder maxNumLineSearchIterations(int maxNumLineSearchIterations)
maxNumLineSearchIterations
- > 0public NeuralNetConfiguration.Builder layer(Layer layer)
@Deprecated public NeuralNetConfiguration.Builder stepFunction(StepFunction stepFunction)
public NeuralNetConfiguration.ListBuilder list()
.list()
.layer(new DenseLayer.Builder()...build())
...
.layer(new OutputLayer.Builder()...build())
public NeuralNetConfiguration.ListBuilder list(Layer... layers)
.list(
new DenseLayer.Builder()...build(),
...,
new OutputLayer.Builder()...build())
layers
- The layer configurations for the networkpublic ComputationGraphConfiguration.GraphBuilder graphBuilder()
public NeuralNetConfiguration.Builder seed(long seed)
public NeuralNetConfiguration.Builder optimizationAlgo(OptimizationAlgorithm optimizationAlgo)
optimizationAlgo
- Optimization algorithm to use when trainingpublic NeuralNetConfiguration.Builder clone()
public NeuralNetConfiguration.Builder activation(org.nd4j.linalg.activations.IActivation activationFunction)
activation(Activation)
public NeuralNetConfiguration.Builder activation(org.nd4j.linalg.activations.Activation activation)
public NeuralNetConfiguration.Builder weightInit(WeightInit weightInit)
WeightInit
public NeuralNetConfiguration.Builder weightInit(Distribution distribution)
.weightInit(WeightInit.DISTRIBUTION).dist(distribution)
distribution
- Distribution to use for weight initializationpublic NeuralNetConfiguration.Builder biasInit(double biasInit)
biasInit
- Constant for bias initializationpublic NeuralNetConfiguration.Builder dist(Distribution dist)
weightInit(Distribution)
public NeuralNetConfiguration.Builder l1(double l1)
public NeuralNetConfiguration.Builder l2(double l2)
public NeuralNetConfiguration.Builder l1Bias(double l1Bias)
public NeuralNetConfiguration.Builder l2Bias(double l2Bias)
public NeuralNetConfiguration.Builder dropOut(double inputRetainProbability)
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/
inputRetainProbability
- Dropout probability (probability of retaining each input activation value for a layer)dropOut(IDropout)
public NeuralNetConfiguration.Builder dropOut(IDropout dropout)
dropout
- Dropout, such as Dropout
, GaussianDropout
,
GaussianNoise
etcpublic NeuralNetConfiguration.Builder weightNoise(IWeightNoise weightNoise)
DropConnect
and
WeightNoise
) for the layers in this network.weightNoise
- Weight noise instance to use@Deprecated public NeuralNetConfiguration.Builder updater(Updater updater)
updater(IUpdater)
public NeuralNetConfiguration.Builder updater(org.nd4j.linalg.learning.config.IUpdater updater)
Adam
or Nesterovs
updater
- Updater to usepublic NeuralNetConfiguration.Builder biasUpdater(org.nd4j.linalg.learning.config.IUpdater updater)
updater(IUpdater)
updater
- Updater to use for bias parameterspublic NeuralNetConfiguration.Builder gradientNormalization(GradientNormalization gradientNormalization)
GradientNormalization
for detailsgradientNormalization
- Type of normalization to use. Defaults to None.GradientNormalization
public NeuralNetConfiguration.Builder gradientNormalizationThreshold(double threshold)
public NeuralNetConfiguration.Builder convolutionMode(ConvolutionMode convolutionMode)
ConvolutionMode
for details. Defaults to ConvolutionMode.TRUNCATEconvolutionMode
- Convolution mode to usepublic NeuralNetConfiguration.Builder cudnnAlgoMode(ConvolutionLayer.AlgoMode cudnnAlgoMode)
ConvolutionLayer.AlgoMode
for details. Defaults to "PREFER_FASTEST", but "NO_WORKSPACE" uses less memory.
cudnnAlgoMode
- cuDNN algo mode to usepublic NeuralNetConfiguration.Builder constrainAllParameters(LayerConstraint... constraints)
constraints
- Constraints to apply to all parameters of all layerspublic NeuralNetConfiguration.Builder constrainBias(LayerConstraint... constraints)
constraints
- Constraints to apply to all bias parameters of all layerspublic NeuralNetConfiguration.Builder constrainWeights(LayerConstraint... constraints)
constraints
- Constraints to apply to all weight parameters of all layerspublic NeuralNetConfiguration build()
Copyright © 2018. All rights reserved.