Skip to main content
Version: 0.11.x

Function: softmax()

softmax(src, dst, axis?): Tensor

Defined in: extensions/math.ts:60

Computes the softmax activation along a specified axis on a float32 source tensor and writes the result to a destination tensor.

Parameters​

src​

Tensor

The input source tensor. Expected shape [d1, ..., dn] with data type float32.

dst​

Tensor

The pre-allocated destination tensor to write the result to. Expected shape [d1, ..., dn] matching src with data type float32.

axis?​

number = -1

The dimension along which softmax is computed. Negative indexing is supported (e.g. -1 for the last dimension). Defaults to -1.

Returns​

Tensor

The destination tensor dst containing the softmax output of shape [d1, ..., dn] and data type float32.

Throws​

With code INVALID_ARGUMENT if tensor shapes, data types, or axis are invalid, RESOURCE_BUSY if a tensor is in use, or RESOURCE_DISPOSED if either tensor was disposed.