public abstract class DifferentialFunction extends Object
Modifier and Type | Field and Description |
---|---|
protected int[] |
dimensions |
protected Object[] |
extraArgs |
protected boolean |
inPlace |
protected String |
ownName |
protected boolean |
ownNameSetWithDefault |
protected SameDiff |
sameDiff |
protected INDArray |
scalarValue |
Constructor and Description |
---|
DifferentialFunction() |
DifferentialFunction(boolean sameDiff) |
DifferentialFunction(SameDiff sameDiff,
boolean inPlace,
Object[] extraArgs) |
DifferentialFunction(SameDiff sameDiff,
boolean inPlace,
SDVariable[] args)
Add the various arguments for
this function
|
DifferentialFunction(SameDiff sameDiff,
NodeDef nodeDef,
Map<String,AttrValue> attributesForNode,
GraphDef graph)
Initialize the function from the given
NodeDef |
DifferentialFunction(SameDiff sameDiff,
Object[] extraArgs) |
DifferentialFunction(SameDiff sameDiff,
Onnx.NodeProto node,
Map<String,Onnx.AttributeProto> attributesForNode,
Onnx.GraphProto graph)
Initialize the function from the given
Onnx.NodeProto |
DifferentialFunction(SameDiff sameDiff,
SDVariable[] args) |
Modifier and Type | Method and Description |
---|---|
SDVariable |
arg()
Return the first argument
|
SDVariable |
arg(int num)
Return the specified argument for this function
|
String[] |
argNames() |
SDVariable[] |
args()
Return the arguments for a given function
|
Map<String,Map<String,AttributeAdapter>> |
attributeAdaptersForFunction()
Returns the
AttributeAdapter s for each of the
possible ops for import (typically tensorflow and onnx)
See AttributeAdapter for more information on what the
adapter does. |
List<DataType> |
calculateOutputDataTypes(List<DataType> dataTypes)
Calculate the data types for the output arrays.
|
List<LongShapeDescriptor> |
calculateOutputShape()
Calculate the output shape for this op
|
List<LongShapeDescriptor> |
calculateOutputShape(OpContext oc) |
abstract void |
clearArrays()
Clear the input and output INDArrays, if any are set
|
String |
configFieldName()
Returns the name of the field to be used for looking up field names.
|
void |
configureWithSameDiff(SameDiff sameDiff) |
List<SDVariable> |
diff(List<SDVariable> i_v1)
Perform automatic differentiation
wrt the input variables
|
abstract List<SDVariable> |
doDiff(List<SDVariable> f1)
The actual implementation for automatic differentiation.
|
DifferentialFunction |
dup()
Duplicate this function
|
boolean |
equals(Object o) |
protected Boolean |
getBooleanFromProperty(String propertyName,
Map<String,Object> properties) |
protected Double |
getDoubleValueFromProperty(String propertyName,
Map<String,Object> properties) |
INDArray |
getInputArgument(int index) |
protected Integer |
getIntValueFromProperty(String propertyName,
Map<String,Object> properties) |
protected Long |
getLongValueFromProperty(String propertyName,
Map<String,Object> properties) |
int |
getNumOutputs() |
protected String |
getStringFromProperty(String propertyName,
Map<String,Object> properties) |
Object |
getValue(Field property)
Get the value for a given property
for this function
|
int |
hashCode() |
abstract void |
initFromOnnx(Onnx.NodeProto node,
SameDiff initWith,
Map<String,Onnx.AttributeProto> attributesForNode,
Onnx.GraphProto graph)
Iniitialize the function from the given
Onnx.NodeProto |
abstract void |
initFromTensorFlow(NodeDef nodeDef,
SameDiff initWith,
Map<String,AttrValue> attributesForNode,
GraphDef graph)
Initialize the function from the given
NodeDef |
boolean |
isConfigProperties()
Returns true if the fields for this class should be looked up from a configuration class.
|
SDVariable |
larg()
The left argument for this function
|
Map<String,Map<String,PropertyMapping>> |
mappingsForFunction()
Returns the mappings for a given function (
for tensorflow and onnx import mapping properties
of this function).
|
abstract String |
onnxName()
The opName of this function in onnx
|
String[] |
onnxNames()
The opName of this function in onnx
|
String |
opName()
The name of the op
|
int |
opNum()
The number of the op (mainly for old legacy XYZ ops
like
Op ) |
Op.Type |
opType()
The type of the op
|
List<SDVariable> |
outputs() |
SDVariable |
outputVariable() |
SDVariable[] |
outputVariables()
Return the output variables for this differential function.
|
abstract SDVariable[] |
outputVariables(String baseName)
Return the output functions for this differential function.
|
String[] |
outputVariablesNames() |
Map<String,Object> |
propertiesForFunction()
Returns the properties for a given function
|
SDVariable |
rarg()
The right argument for this function.
|
void |
replaceArg(int i,
SDVariable newArg)
Replace argument at the specfied index
|
protected void |
setInstanceId() |
void |
setPropertiesForFunction(Map<String,Object> properties) |
void |
setValueFor(Field target,
Object value)
Set the value for this function.
|
abstract String |
tensorflowName()
The opName of this function tensorflow
|
String[] |
tensorflowNames()
The opName of this function tensorflow
|
protected SameDiff sameDiff
protected boolean inPlace
protected INDArray scalarValue
protected int[] dimensions
protected Object[] extraArgs
protected String ownName
protected boolean ownNameSetWithDefault
public DifferentialFunction()
public DifferentialFunction(boolean sameDiff)
public DifferentialFunction(SameDiff sameDiff, NodeDef nodeDef, Map<String,AttrValue> attributesForNode, GraphDef graph)
NodeDef
nodeDef
- public DifferentialFunction(SameDiff sameDiff, Onnx.NodeProto node, Map<String,Onnx.AttributeProto> attributesForNode, Onnx.GraphProto graph)
Onnx.NodeProto
node
- public DifferentialFunction(SameDiff sameDiff, boolean inPlace, Object[] extraArgs)
sameDiff
- extraArgs
- public DifferentialFunction(SameDiff sameDiff, Object[] extraArgs)
sameDiff
- extraArgs
- public DifferentialFunction(SameDiff sameDiff, SDVariable[] args)
sameDiff
- args
- public DifferentialFunction(SameDiff sameDiff, boolean inPlace, SDVariable[] args)
sameDiff
- inPlace
- args
- public Map<String,Map<String,AttributeAdapter>> attributeAdaptersForFunction()
AttributeAdapter
s for each of the
possible ops for import (typically tensorflow and onnx)
See AttributeAdapter
for more information on what the
adapter does.
Similar to mappingsForFunction()
, the returned map
contains a AttributeAdapter
for each field name
when one is present. (It is optional for one to exist)_public Map<String,Map<String,PropertyMapping>> mappingsForFunction()
public Map<String,Object> propertiesForFunction()
public void configureWithSameDiff(SameDiff sameDiff)
protected Boolean getBooleanFromProperty(String propertyName, Map<String,Object> properties)
protected String getStringFromProperty(String propertyName, Map<String,Object> properties)
protected Integer getIntValueFromProperty(String propertyName, Map<String,Object> properties)
protected Long getLongValueFromProperty(String propertyName, Map<String,Object> properties)
protected Double getDoubleValueFromProperty(String propertyName, Map<String,Object> properties)
public Object getValue(Field property)
property
- the property to getpublic void setValueFor(Field target, Object value)
ND4JIllegalStateException
will be thrown.target
- the target fieldvalue
- the value to setpublic boolean isConfigProperties()
public String configFieldName()
isConfigProperties()
to facilitate mapping fields for model import.public void replaceArg(int i, SDVariable newArg)
i
- the indexnewArg
- the new argumentpublic SDVariable[] outputVariables()
public SDVariable outputVariable()
public List<SDVariable> outputs()
public String[] outputVariablesNames()
public abstract SDVariable[] outputVariables(String baseName)
public abstract List<SDVariable> doDiff(List<SDVariable> f1)
f1
- public SDVariable[] args()
public SDVariable arg(int num)
num
- Number of the argument. Must be in range 0 to numArgs - 1 inclusivepublic String[] argNames()
public SDVariable arg()
public List<SDVariable> diff(List<SDVariable> i_v1)
i_v1
- the input variablesprotected void setInstanceId()
public String opName()
public Op.Type opType()
public int opNum()
Op
)public INDArray getInputArgument(int index)
public abstract void initFromTensorFlow(NodeDef nodeDef, SameDiff initWith, Map<String,AttrValue> attributesForNode, GraphDef graph)
NodeDef
nodeDef
- initWith
- attributesForNode
- graph
- public abstract void initFromOnnx(Onnx.NodeProto node, SameDiff initWith, Map<String,Onnx.AttributeProto> attributesForNode, Onnx.GraphProto graph)
Onnx.NodeProto
node
- initWith
- attributesForNode
- graph
- public SDVariable larg()
public SDVariable rarg()
ND4JIllegalStateException
public DifferentialFunction dup()
public List<LongShapeDescriptor> calculateOutputShape()
public List<LongShapeDescriptor> calculateOutputShape(OpContext oc)
public List<DataType> calculateOutputDataTypes(List<DataType> dataTypes)
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.dataTypes
- The data types of the inputspublic String[] onnxNames()
public String[] tensorflowNames()
public abstract String onnxName()
public abstract String tensorflowName()
public int getNumOutputs()
public abstract void clearArrays()
Copyright © 2022. All rights reserved.