softmax

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

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

Parameters

inputs Operation

The inputs to the softmax function.

Return Value

Type: Operation

The operation.

Examples

import std.math : approxEqual;
import dopt.core : evaluate;

auto y = float32([1, 5], [1.0f, 2.0f, 3.0f, 1.0f, 2.0f]).softmax();

assert(approxEqual(
    y.evaluate().get!float,
    [0.0674508, 0.18335, 0.498398, 0.0674508, 0.18335]
));

Meta