Function softmax

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

Operation softmax (
  Operation inputs,
  string mod = __MODULE__,
  ulong line = cast(ulong)__LINE__
);

Parameters

NameDescription
inputs The inputs to the softmax function.

Returns

The operation.

Example

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().as!float,
    [0.0674508, 0.18335, 0.498398, 0.0674508, 0.18335]
));