You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.nn.LogSoftmax.txt 1.3 kB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. Class mindspore.nn.LogSoftmax(axis=-1)
  2. Log Softmax激活函数。
  3. 按元素计算Log Softmax激活函数。
  4. 输入经Softmax函数、Log函数转换后,值的范围在[-inf,0)。
  5. Log Softmax定义如下:
  6. .. math::
  7. \text{logsoftmax}(x_i) = \log \left(\frac{\exp(x_i)}{\sum_{j=0}^{n-1} \exp(x_j)}\right),
  8. 其中,:math:`x_i` 是输入Tensor的一个元素。
  9. 参数:
  10. axis (int):Log Softmax运算的axis,-1表示最后一个维度。默认值:-1。
  11. 输入:
  12. - **x** (Tensor):Log Softmax的输入,数据类型为float16或float32。
  13. 输出:
  14. Tensor,数据类型和shape与`x`相同,值的范围在[-inf,0)。
  15. 异常:
  16. TypeError:`axis`不是int。
  17. TypeError:`x`的数据类型既不是float16也不是float32。
  18. ValueError:`axis`不在[-len(x), len(x))范围中。
  19. 支持平台:
  20. ``Ascend`` ``GPU`` ``CPU``
  21. 示例:
  22. >>> x = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]), mindspore.float32)
  23. >>> log_softmax = nn.LogSoftmax()
  24. >>> output = log_softmax(x)
  25. >>> print(output)
  26. [[-5.00672150e+00 -6.72150636e-03 -1.20067215e+01]
  27. [-7.00091219e+00 -1.40009127e+01 -9.12250078e-04]]