logSoftmax

log exp(x_i) / sum_i (exp(x_i))

logSoftmax
(
T
size_t dim
alias Storage
)
(
Variable!(T, dim, Storage) x
)

Examples

test fast math functions

import grain.testing;
import numir;
import mir.ndslice;
import std.meta;

foreach (f; AliasSeq!(sigmoid, tanh, reciprocal, neg, exp, log, sin, cos,
        tan, x => pow(x, 2.0f), logSoftmax)) {
    auto hx = uniform!float(2, 3).slice.variable(true);
    auto hgy = uniform!float(2, 3).slice.variable;
    gradCheckChain!f(hx, hgy, 1e-3, 5e-2, 5e-2);
}

Meta