Class DifferentialFunction

    • Field Detail

      • inPlace

        protected boolean inPlace
      • scalarValue

        protected INDArray scalarValue
      • dimensions

        protected int[] dimensions
      • extraArgs

        protected Object[] extraArgs
      • ownName

        protected String ownName
      • ownNameSetWithDefault

        protected boolean ownNameSetWithDefault
    • Constructor Detail

      • DifferentialFunction

        public DifferentialFunction()
      • DifferentialFunction

        public DifferentialFunction​(boolean sameDiff)
      • DifferentialFunction

        public DifferentialFunction​(SameDiff sameDiff,
                                    boolean inPlace,
                                    Object[] extraArgs)
        Parameters:
        sameDiff -
        extraArgs -
      • DifferentialFunction

        public DifferentialFunction​(SameDiff sameDiff,
                                    Object[] extraArgs)
        Parameters:
        sameDiff -
        extraArgs -
      • DifferentialFunction

        public DifferentialFunction​(SameDiff sameDiff,
                                    SDVariable[] args)
        Parameters:
        sameDiff -
        args -
      • DifferentialFunction

        public DifferentialFunction​(SameDiff sameDiff,
                                    boolean inPlace,
                                    SDVariable[] args)
        Add the various arguments for this function
        Parameters:
        sameDiff -
        inPlace -
        args -
    • Method Detail

      • mappingsForFunction

        public Map<String,​Map<String,​PropertyMapping>> mappingsForFunction()
        Returns the mappings for a given function ( for tensorflow and onnx import mapping properties of this function). The mapping is indexed by field name. If the function has no properties, this returned map will be empty. Note that some functions have multiple names. This function returns a map indexed by each alias it has for a given name. These names include both onnx and tensorflow names (which might be 1 or more)
        Returns:
      • propertiesForFunction

        public Map<String,​Object> propertiesForFunction()
        Returns the properties for a given function
        Returns:
      • configureWithSameDiff

        public void configureWithSameDiff​(SameDiff sameDiff)
      • setPropertiesForFunction

        public void setPropertiesForFunction​(Map<String,​Object> properties)
      • getLongValueFromProperty

        protected Long getLongValueFromProperty​(String propertyName,
                                                Map<String,​Object> properties)
      • getValue

        public Object getValue​(Field property)
        Get the value for a given property for this function
        Parameters:
        property - the property to get
        Returns:
        the value for the function if it exists
      • setValueFor

        public void setValueFor​(Field target,
                                Object value)
        Set the value for this function. Note that if value is null an ND4JIllegalStateException will be thrown.
        Parameters:
        target - the target field
        value - the value to set
      • isConfigProperties

        public boolean isConfigProperties()
        Returns true if the fields for this class should be looked up from a configuration class.
        Returns:
      • configFieldName

        public String configFieldName()
        Returns the name of the field to be used for looking up field names. This should be used in conjunction with isConfigProperties() to facilitate mapping fields for model import.
        Returns:
      • replaceArg

        public void replaceArg​(int i,
                               SDVariable newArg)
        Replace argument at the specified index
        Parameters:
        i - the index
        newArg - the new argument
      • outputVariables

        public SDVariable[] outputVariables()
        Return the output variables for this differential function. Note that this op *may* dynamically generate variable outputs.
        Returns:
      • outputVariable

        public SDVariable outputVariable()
        Returns:
        The output variable, or the first output variable, if multiple outputs exist
      • outputVariablesNames

        public String[] outputVariablesNames()
      • outputVariables

        public abstract SDVariable[] outputVariables​(String baseName)
        Return the output functions for this differential function.
        Returns:
      • doDiff

        public abstract List<SDVariable> doDiff​(List<SDVariable> f1)
        The actual implementation for automatic differentiation.
        Parameters:
        f1 -
        Returns:
      • args

        public SDVariable[] args()
        Return the arguments for a given function
        Returns:
        the arguments for a given function
      • arg

        public SDVariable arg​(int num)
        Return the specified argument for this function
        Parameters:
        num - Number of the argument. Must be in range 0 to numArgs - 1 inclusive
        Returns:
        Specified argument
      • argNames

        public String[] argNames()
      • arg

        public SDVariable arg()
        Return the first argument
        Returns:
      • diff

        public List<SDVariable> diff​(List<SDVariable> i_v1)
        Perform automatic differentiation wrt the input variables
        Parameters:
        i_v1 - the input variables
        Returns:
        the differentiated output wrt each input variable
      • setInstanceId

        protected void setInstanceId()
      • opName

        public String opName()
        The name of the op
        Returns:
      • opType

        public Op.Type opType()
        The type of the op
        Returns:
      • opNum

        public int opNum()
        The number of the op (mainly for old legacy XYZ ops like Op)
        Returns:
      • getInputArgument

        public INDArray getInputArgument​(int index)
      • initFromTensorFlow

        public abstract void initFromTensorFlow​(NodeDef nodeDef,
                                                SameDiff initWith,
                                                Map<String,​AttrValue> attributesForNode,
                                                GraphDef graph)
        Initialize the function from the given NodeDef
        Parameters:
        nodeDef -
        initWith -
        attributesForNode -
        graph -
      • larg

        public SDVariable larg()
        The left argument for this function
        Returns:
      • rarg

        public SDVariable rarg()
        The right argument for this function. Note that this assumes that there are 2 args for this function, if 2 are not set, it throws an ND4JIllegalStateException
        Returns:
      • calculateOutputShape

        public List<LongShapeDescriptor> calculateOutputShape()
        Calculate the output shape for this op
        Returns:
        List of output shape descriptors
      • calculateOutputDataTypes

        public List<DataType> calculateOutputDataTypes​(List<DataType> dataTypes)
        Calculate the data types for the output arrays. Though datatypes can also be inferred from calculateOutputShape(), this method differs in that it does not require the input arrays to be populated. This is important as it allows us to do greedy datatype inference for the entire net - even if arrays are not available.
        Parameters:
        dataTypes - The data types of the inputs
        Returns:
        The data types of the outputs
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • onnxNames

        public String[] onnxNames()
        The opName of this function in onnx
        Returns:
      • tensorflowNames

        public String[] tensorflowNames()
        The opName of this function tensorflow
        Returns:
      • onnxName

        public abstract String onnxName()
        The opName of this function in onnx
        Returns:
      • tensorflowName

        public abstract String tensorflowName()
        The opName of this function tensorflow
        Returns:
      • getNumOutputs

        public int getNumOutputs()
      • clearArrays

        public abstract void clearArrays()
        Clear the input and output INDArrays, if any are set