jax.scipy.special.logsumexp#

jax.scipy.special.logsumexp(a: ArrayLike, axis: Axis = None, b: ArrayLike | None = None, keepdims: bool = False, return_sign: Literal[False] = False, where: ArrayLike | None = None) Array[源代码]#
jax.scipy.special.logsumexp(a: ArrayLike, axis: Axis = None, b: ArrayLike | None = None, keepdims: bool = False, *, return_sign: Literal[True], where: ArrayLike | None = None) tuple[Array, Array]
jax.scipy.special.logsumexp(a: ArrayLike, axis: Axis = None, b: ArrayLike | None = None, keepdims: bool = False, return_sign: bool = False, where: ArrayLike | None = None) Array | tuple[Array, Array]

Log-sum-exp 约简。

JAX 实现的 scipy.special.logsumexp()

\[\mathrm{logsumexp}(a) = \mathrm{log} \sum_j b \cdot \mathrm{exp}(a_{ij})\]

其中 \(j\) 索引范围覆盖一个或多个要约简的维度。

参数:
  • a – 输入数组

  • axis – 要在其上进行约简的轴或轴。可以是 None、一个整数或一个整数元组。

  • b\(\mathrm{exp}(a)\) 的比例因子。必须可广播到 a 的形状。

  • keepdims – 如果为 True,则约简的轴将保留在输出中,作为大小为 1 的维度。

  • return_sign – 如果为 True,则输出将是一个 (result, sign) 对,其中 sign 是总和的符号,result 包含其绝对值的对数。如果为 False,则仅返回 result,如果总和为负数,它将包含 NaN 值。

  • where – 要包含在约简中的元素。

返回:

根据 return_sign 参数的值,返回数组 result 或数组对 (result, sign)