Rate this Page

torch.Tensor.tolist#

Tensor.tolist()listornumber#

Returns the tensor as a (nested) list. For scalars, a standardPython number is returned, just like withitem().Tensors are automatically moved to the CPU first if necessary.

This operation is not differentiable.

Examples:

>>>a=torch.randn(2,2)>>>a.tolist()[[0.012766935862600803, 0.5415473580360413], [-0.08909505605697632, 0.7729271650314331]]>>>a[0,0].tolist()0.012766935862600803