mindspore.ops.logit
- mindspore.ops.logit(input, eps=None)[源代码]
- 逐元素计算Tensor的logit值。 \[\begin{split}\begin{align} y_{i} & = \ln(\frac{z_{i}}{1 - z_{i}}) \\ z_{i} & = \begin{cases} input_{i} & \text{if eps is None} \\ \text{eps} & \text{if } input_{i} \lt \text{eps} \\ input_{i} & \text{if } \text{eps} \leq input_{i} \leq 1 - \text{eps} \\ 1 - \text{eps} & \text{if } input_{i} \gt 1 - \text{eps} \end{cases} \end{align}\end{split}\]- 参数:
- input (Tensor) - Tensor输入,其数据类型为float16、float32或float64。 
- eps (float, 可选) - epsilon值,当eps不是None时,输入的数值界限被定义[eps, 1-eps],否则没有界限。 默认值: - None。
 
- 返回:
- Tensor,具有与 input 相同的shape。 
- 异常:
- TypeError - eps 不是float类型。 
- TypeError - input 不是Tensor类型。 
- TypeError - input 的数据类型不是float16、float32或float64。 
 
- 支持平台:
- Ascend- GPU- CPU
 - 样例: - >>> import numpy as np >>> from mindspore import Tensor, ops >>> x = Tensor(np.array([0.1, 0.2, 0.3]).astype(np.float32)) >>> output = ops.logit(x, eps=1e-5) >>> print(output) [-2.1972246 -1.3862944 -0.8472978]