mindspore.ops.logsumexp
- mindspore.ops.logsumexp(input, dim, keepdim=False)[源代码]
计算tensor在指定维度上的指数和的对数。
- 参数:
input (Tensor) - 输入tensor。
dim (Union[int, tuple(int), list(int)]) - 指定维度。如果为
()
,计算 input 中的所有元素。keepdim (bool,可选) - 输出tensor是否保留维度。默认
False
。
- 返回:
Tensor
- 支持平台:
Ascend
GPU
CPU
样例:
>>> import mindspore >>> input = mindspore.tensor([[9., 3, 4, 5], ... [5, 2, 7, 4], ... [8, 1, 3, 6]]) >>> # case 1: By default, compute the log of summed exponential of all elements. >>> output = mindspore.ops.logsumexp(input, ()) >>> print(output) 9.475807 >>> >>> # case 2: Compute the log of summed exponential along dim 0. >>> output = mindspore.ops.logsumexp(input, 0) >>> print(output) [9.326562 3.4076054 7.065884 6.4076056] >>> >>> # case 3: If keepdim=True, the output shape will be same of that of the input. >>> output = mindspore.ops.logsumexp(input, 1, True) >>> print(output) [[9.02716 ] [7.175515] [8.133643]]