SoftmaxOperator
public class SoftmaxOperator: ActivationOperator
Softmax activations.
y = exp(x) / reduce_sum(exp(x), dim)
Default dim
is the last dimension of input tensors.
Note
The operator assumens all input tensors have same rank. If not, it could not do the calculation.-
Reduce summing dimension. The value should be
>=0
. Any negative value will be automatically making this attribute value to-1
.Note
-1
is a special value indicating last dim.Declaration
Swift
public var dim: Int = -1
-
Convenience initializer Subclass required to override this function to assign
cpuComputeBlock
andmetalKernelFuncLabel
Declaration
Swift
required public convenience init(computationDelegate: OperatorCalculationDelegate? = nil)
Parameters
computationDelegate
computationDelegate
-
Initial by setting
dim
value.Declaration
Swift
public convenience init(computationDelegate: OperatorCalculationDelegate? = nil, dim: Int)
Parameters
computationDelegate
computationDelegate description
dim
reduce dim
-
Override this function from
UnaryOperaotr
to do additional checking validation bewtweendim
andshapes
.Declaration
Swift
public override func outputShape(shapeArray shapes: [TensorShape]) -> [TensorShape]?
Parameters
shapes
shapes description
Return Value
return value description
-
Override computaion methods. This computation just call other operators.
Declaration
Swift
public override func compute(_ computationMode: OperatorComputationMode = SerranoEngine.configuredEngine.defaultComputationMode)
Parameters
computationMode
computationMode
-
Attribute
dim
as aScalarSymbol
.Declaration
Swift
public override func paramSymbols() -> [GraphSymbol]
Return Value
Array of GraphSymbol