现在位置: 首页 > PyTorch 教程 > 正文

PyTorch torch.set_printoptions 函数


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

torch.set_printoptions 是 PyTorch 中用于设置张量打印选项的函数。

函数定义

torch.set_printoptions(precision, threshold, edgeitems, linewidth, profile, sci_mode)

使用示例

实例

import torch

# 设置打印精度为 2 位小数
torch.set_printoptions(precision=2)

x = torch.randn(3, 3)
print(x)

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