Class BaseLayer.Builder<T extends BaseLayer.Builder<T>>

    • Field Detail

      • activationFn

        protected IActivation activationFn
        Set the activation function for the layer. This overload can be used for custom IActivation 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
      • biasUpdater

        protected IUpdater biasUpdater
        Gradient updater configuration, for the biases only. If not set, biases will use the updater as set by updater(IUpdater)
      • 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.
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • activation

        public T activation​(IActivation activationFunction)
        Set the activation function for the layer. This overload can be used for custom IActivation instances
        Parameters:
        activationFunction - Activation function to use for the layer
      • activation

        public T activation​(Activation activation)
        Set the activation function for the layer, from an Activation 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). Use l1Bias(double) to configure the l1 regularization coefficient for the bias.
      • l1Bias

        public T l1Bias​(double l1Bias)
        L1 regularization coefficient for the bias. Default: 0. See also l1(double)
      • 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 - see WeightDecay 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). See WeightDecay for more details.
        Parameters:
        coefficient - Weight decay regularization coefficient
        applyLR - Whether the learning rate should be multiplied in when performing weight decay updates. See WeightDecay for more details.
        See Also:
        weightDecay(double, boolean)
      • weightDecayBias

        public BaseLayer.Builder weightDecayBias​(double coefficient,
                                                 boolean applyLR)
        Weight decay for the biases only - see weightDecay(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 example WeightDecay
        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 example WeightDecay
        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
      • updater

        public T updater​(IUpdater updater)
        Gradient updater. For example, Adam or Nesterovs
        Parameters:
        updater - Updater to use
      • biasUpdater

        public T biasUpdater​(IUpdater biasUpdater)
        Gradient updater configuration, for the biases only. If not set, biases will use the updater as set by updater(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 as DropConnect and WeightNoise) for this layer
        Parameters:
        weightNoise - Weight noise instance to use