PyTorch torch.lgamma 函数
torch.lgamma 是 PyTorch 中用于计算伽马函数对数的函数。
函数定义
torch.lgamma(input, out=None)
使用示例
实例
import torch
# 计算伽马函数的对数
x = torch.tensor([1.0, 2.0, 3.0, 4.0])
y = torch.lgamma(x)
print("lgamma(x):", y)
# 计算伽马函数的对数
x = torch.tensor([1.0, 2.0, 3.0, 4.0])
y = torch.lgamma(x)
print("lgamma(x):", y)
输出结果为:
lgamma(x): tensor([0.0000, 0.0000, 0.6931, 1.7918])

Pytorch torch 参考手册