Class DefaultGradient

    • Field Detail

      • DEFAULT_FLATTENING_ORDER

        public static final char DEFAULT_FLATTENING_ORDER
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultGradient

        public DefaultGradient()
      • DefaultGradient

        public DefaultGradient​(INDArray flattenedGradient)
    • Method Detail

      • gradient

        public INDArray gradient()
        Description copied from interface: Gradient
        The full gradient as one flat vector
        Specified by:
        gradient in interface Gradient
        Returns:
      • clear

        public void clear()
        Description copied from interface: Gradient
        Clear residual parameters (useful for returning a gradient and then clearing old objects)
        Specified by:
        clear in interface Gradient
      • getGradientFor

        public INDArray getGradientFor​(String variable)
        Description copied from interface: Gradient
        The gradient for the given variable
        Specified by:
        getGradientFor in interface Gradient
        Parameters:
        variable - the variable to get the gradient for
        Returns:
        the gradient for the given variable or null
      • setGradientFor

        public INDArray setGradientFor​(String variable,
                                       INDArray newGradient)
        Description copied from interface: Gradient
        Update gradient for the given variable
        Specified by:
        setGradientFor in interface Gradient
        Parameters:
        variable - the variable to get the gradient for
        newGradient - the gradient values
        Returns:
        the gradient for the given variable or null
      • setGradientFor

        public INDArray setGradientFor​(String variable,
                                       INDArray gradient,
                                       Character flatteningOrder)
        Description copied from interface: Gradient
        Update gradient for the given variable; also (optionally) specify the order in which the array should be flattened to a row vector
        Specified by:
        setGradientFor in interface Gradient
        Parameters:
        variable - the variable to get the gradient for
        gradient - the gradient values
        flatteningOrder - the order in which gradients should be flattened (null ok - default)
        Returns:
        the gradient for the given variable or null
      • flatteningOrderForVariable

        public Character flatteningOrderForVariable​(String variable)
        Description copied from interface: Gradient
        Return the gradient flattening order for the specified variable, or null if it is not explicitly set
        Specified by:
        flatteningOrderForVariable in interface Gradient
        Parameters:
        variable - Variable to return the gradient flattening order for
        Returns:
        Order in which the specified variable's gradient should be flattened