softmax

Creates an operation representing the computation required for a softmax layer.

softmax
(
,
string mod = __MODULE__
,
size_t line = __LINE__
)

Parameters

inputs
Type: Operation

The inputs to the softmax function.

Return Value

Type: Operation

The operation.

Examples

1 import std.math : approxEqual;
2 import dopt.core : evaluate;
3 
4 auto y = float32([1, 5], [1.0f, 2.0f, 3.0f, 1.0f, 2.0f]).softmax();
5 
6 assert(approxEqual(
7     y.evaluate().as!float,
8     [0.0674508, 0.18335, 0.498398, 0.0674508, 0.18335]
9 ));

Meta