mlx.core.softmax

目錄

mlx.core.softmax#

softmax(a: array, /, axis: None | int | Sequence[int] = None, *, precise: bool = False, stream: StreamOrDevice = None) → array#

Perform the softmax along the given axis.

This operation is a numerically stable version of:

exp(a) / sum(exp(a), axis, keepdims=True)
參數:
  • a (array) -- 輸入陣列。

  • axis (int or list(int), optional) -- Optional axis or axes to compute the softmax over. If unspecified this performs the softmax over the full array.

  • precise (bool, optional) -- Accumulate in float32 for inputs of lower precision. Otherwise the accumulation type matches the input, which can lose precision over long reduction axes. Default: False.

回傳值:

The output of the softmax.

回傳值型別:

array