torch.Tensor.tolist¶ Tensor.tolist() → list 或 number¶ 将张量返回为(嵌套的)列表。对于标量,就像 item() 一样,返回标准的 Python 数字。如有必要,张量会自动首先移至 CPU。 此操作不可微分。 示例 >>> a = torch.randn(2, 2) >>> a.tolist() [[0.012766935862600803, 0.5415473580360413], [-0.08909505605697632, 0.7729271650314331]] >>> a[0,0].tolist() 0.012766935862600803