jax.scipy.special.softmax#

jax.scipy.special.softmax(x, /, *, axis=None)[源代码]#

Softmax 函数。

scipy.special.softmax()的 JAX 实现。

计算将元素重新缩放到 \([0, 1]\) 范围的函数,使得沿 axis 的元素总和为 \(1\)

\[\mathrm{softmax}(x) = \frac{\exp(x_i)}{\sum_j \exp(x_j)}\]
参数:
  • x (ArrayLike) – 输入数组

  • axis (int | tuple[int, ...] | None) – softmax 应该沿其计算的轴或轴。 在这些维度上求和的 softmax 输出应该总和为 \(1\)

返回:

x 形状相同的数组。

返回类型:

Array

注意

如果任何输入值为 +inf,结果将全部为 NaN:这反映了 inf / inf 在浮点数学的上下文中没有明确定义。

另请参阅

log_softmax()