PyTorch torch.digamma 函数
torch.digamma 是 PyTorch 中用于逐元素计算 psi 函数(对数导数)的函数。
函数定义
torch.digamma(input, *, out=None)
使用示例
实例
import torch
# 计算 psi 函数示例
x = torch.tensor([1.0, 2.0, 3.0, 4.0], dtype=torch.float32)
result = torch.digamma(x)
print(result) # tensor([-0.5772, 0.4228, 1.2561, 2.0312])
# 计算 psi 函数示例
x = torch.tensor([1.0, 2.0, 3.0, 4.0], dtype=torch.float32)
result = torch.digamma(x)
print(result) # tensor([-0.5772, 0.4228, 1.2561, 2.0312])

Pytorch torch 参考手册