TUTORIALAI 与数据科学FETCHED

PyTorch torch.lgamma 函数

PyTorch torch.lgamma 函数 Pytorch torch 参考手册 torch.lgamma 是 PyTorch 中用于计算伽马函数对数的函数。 函数定义 torch.lgamma(input, out=None) 使用示例 实例 [mycode4 type='python'] import torch # 计算伽马函数的对数 x = torch.tensor([1.0, 2...

更新于 2026/7/16

教程详情页默认 noindex。

PyTorch torch.lgamma 函数


Pytorch torch 参考手册 Pytorch torch 参考手册

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)

输出结果为:

lgamma(x): tensor([0.0000, 0.0000, 0.6931, 1.7918])

Pytorch torch 参考手册 Pytorch torch 参考手册