PyTorch torch.logit 函数
torch.logit 是 PyTorch 中用于计算 logit 函数的函数,即 log(p / (1-p))。
函数定义
torch.logit(input, eps=None, out=None)
使用示例
实例
import torch
# 计算 logit
x = torch.tensor([0.1, 0.3, 0.5, 0.7, 0.9])
y = torch.logit(x)
print("logit:", y)
# 计算 logit
x = torch.tensor([0.1, 0.3, 0.5, 0.7, 0.9])
y = torch.logit(x)
print("logit:", y)
输出结果为:
logit: tensor([-2.1972, -0.8473, 0.0000, 0.8473, 2.1972])

Pytorch torch 参考手册