Class CompareAndReplace
- java.lang.Object
-
- org.nd4j.autodiff.functions.DifferentialFunction
-
- org.nd4j.linalg.api.ops.BaseOp
-
- org.nd4j.linalg.api.ops.BaseTransformOp
-
- org.nd4j.linalg.api.ops.BaseTransformSameOp
-
- org.nd4j.linalg.api.ops.impl.transforms.comparison.CompareAndReplace
-
- All Implemented Interfaces:
Op
,TransformOp
,TransformSameOp
public class CompareAndReplace extends BaseTransformSameOp
-
-
Field Summary
-
Fields inherited from class org.nd4j.linalg.api.ops.BaseOp
dimensionz, extraArgz, x, xVertexId, y, yVertexId, z, zVertexId
-
Fields inherited from class org.nd4j.autodiff.functions.DifferentialFunction
dimensions, extraArgs, inPlace, ownName, ownNameSetWithDefault, sameDiff, scalarValue
-
-
Constructor Summary
Constructors Constructor Description CompareAndReplace()
CompareAndReplace(SameDiff sameDiff, SDVariable to, SDVariable from, Condition condition)
CompareAndReplace(INDArray x, INDArray y, INDArray z, Condition condition)
With this constructor, op will check each X element against given Condition, and if condition met, element Z will be set to Y value, and X otherwise Pseudocode: z[i] = condition(x[i]) ? y[i] : x[i];CompareAndReplace(INDArray x, INDArray y, Condition condition)
With this constructor, op will check each X element against given Condition, and if condition met, element Z will be set to Y value, and X otherwise PLEASE NOTE: X will be modified inplace.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<DataType>
calculateOutputDataTypes(List<DataType> dataTypes)
Calculate the data types for the output arrays.List<SDVariable>
doDiff(List<SDVariable> grad)
The actual implementation for automatic differentiation.String
onnxName()
The opName of this function in onnxString
opName()
The name of the opint
opNum()
The number of the op (mainly for old legacy XYZ ops likeOp
)Map<String,Object>
propertiesForFunction()
Returns the properties for a given functionvoid
setPropertiesForFunction(Map<String,Object> properties)
String
tensorflowName()
The opName of this function tensorflow-
Methods inherited from class org.nd4j.linalg.api.ops.BaseTransformSameOp
calculateOutputShape, calculateOutputShape, getOpType, opType, resultType, resultType, validateDataTypes
-
Methods inherited from class org.nd4j.linalg.api.ops.BaseTransformOp
z
-
Methods inherited from class org.nd4j.linalg.api.ops.BaseOp
clearArrays, computeVariables, defineDimensions, dimensions, equals, extraArgs, extraArgsBuff, extraArgsDataBuff, getFinalResult, getInputArgument, getNumOutputs, getOpType, hashCode, initFromOnnx, initFromTensorFlow, outputVariables, setX, setY, setZ, toCustomOp, toString, x, y
-
Methods inherited from class org.nd4j.autodiff.functions.DifferentialFunction
arg, arg, argNames, args, attributeAdaptersForFunction, configFieldName, configureWithSameDiff, diff, dup, getBooleanFromProperty, getDoubleValueFromProperty, getIntValueFromProperty, getLongValueFromProperty, getStringFromProperty, getValue, isConfigProperties, larg, mappingsForFunction, onnxNames, outputs, outputVariable, outputVariables, outputVariablesNames, rarg, replaceArg, setInstanceId, setValueFor, tensorflowNames
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.nd4j.linalg.api.ops.Op
clearArrays, extraArgs, extraArgsBuff, extraArgsDataBuff, setExtraArgs, setX, setY, setZ, toCustomOp, x, y, z
-
-
-
-
Constructor Detail
-
CompareAndReplace
public CompareAndReplace(SameDiff sameDiff, SDVariable to, SDVariable from, Condition condition)
-
CompareAndReplace
public CompareAndReplace()
-
CompareAndReplace
public CompareAndReplace(INDArray x, INDArray y, Condition condition)
With this constructor, op will check each X element against given Condition, and if condition met, element Z will be set to Y value, and X otherwise PLEASE NOTE: X will be modified inplace. Pseudocode: z[i] = condition(x[i]) ? y[i] : x[i];- Parameters:
x
-y
-condition
-
-
CompareAndReplace
public CompareAndReplace(INDArray x, INDArray y, INDArray z, Condition condition)
With this constructor, op will check each X element against given Condition, and if condition met, element Z will be set to Y value, and X otherwise Pseudocode: z[i] = condition(x[i]) ? y[i] : x[i];- Parameters:
x
-y
-z
-condition
-
-
-
Method Detail
-
propertiesForFunction
public Map<String,Object> propertiesForFunction()
Description copied from class:DifferentialFunction
Returns the properties for a given function- Overrides:
propertiesForFunction
in classDifferentialFunction
- Returns:
-
setPropertiesForFunction
public void setPropertiesForFunction(Map<String,Object> properties)
- Overrides:
setPropertiesForFunction
in classDifferentialFunction
-
opNum
public int opNum()
Description copied from class:DifferentialFunction
The number of the op (mainly for old legacy XYZ ops likeOp
)- Specified by:
opNum
in interfaceOp
- Overrides:
opNum
in classDifferentialFunction
- Returns:
-
opName
public String opName()
Description copied from class:DifferentialFunction
The name of the op- Specified by:
opName
in interfaceOp
- Overrides:
opName
in classDifferentialFunction
- Returns:
- the opName of this operation
-
onnxName
public String onnxName()
Description copied from class:DifferentialFunction
The opName of this function in onnx
-
tensorflowName
public String tensorflowName()
Description copied from class:DifferentialFunction
The opName of this function tensorflow- Overrides:
tensorflowName
in classBaseOp
- Returns:
-
doDiff
public List<SDVariable> doDiff(List<SDVariable> grad)
Description copied from class:DifferentialFunction
The actual implementation for automatic differentiation.- Specified by:
doDiff
in classDifferentialFunction
- Returns:
-
calculateOutputDataTypes
public List<DataType> calculateOutputDataTypes(List<DataType> dataTypes)
Description copied from class:DifferentialFunction
Calculate the data types for the output arrays. Though datatypes can also be inferred fromDifferentialFunction.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.- Overrides:
calculateOutputDataTypes
in classBaseTransformSameOp
- Parameters:
dataTypes
- The data types of the inputs- Returns:
- The data types of the outputs
-
-