TUTORIALAI 与数据科学FETCHED
PyTorch torch.sqrt 函数
PyTorch torch.sqrt 函数 Pytorch torch 参考手册 torch.sqrt 是 PyTorch 中用于计算张量逐元素平方根的函数。 函数定义 torch.sqrt(input, out=None) 使用示例 实例 [mycode4 type='python'] import torch x = torch.tensor([4.0, 9.0, 16.0, 25.0]) ..
更新于 2026/7/16
教程详情页默认 noindex。
PyTorch torch.sqrt 函数
torch.sqrt 是 PyTorch 中用于计算张量逐元素平方根的函数。
函数定义
torch.sqrt(input, out=None)
使用示例
实例
import torch
x = torch.tensor([4.0, 9.0, 16.0, 25.0])
y = torch.sqrt(x)
print(y)
x = torch.tensor([4.0, 9.0, 16.0, 25.0])
y = torch.sqrt(x)
print(y)
输出结果为:
tensor([2., 3., 4., 5.])
Pytorch torch 参考手册