tolist

paddle. tolist ( x ) [source]

Note

This API is ONLY available in Dygraph mode.

This function translate the paddle.Tensor to python list.

Parameters

x (Tensor) – x is the Tensor we want to translate to list.

Returns

list, A list that contain the same value of current Tensor.

Examples

>>> import paddle

>>> t = paddle.to_tensor([0,1,2,3,4])
>>> expectlist = t.tolist()
>>> print(expectlist)
[0, 1, 2, 3, 4]

>>> expectlist = paddle.tolist(t)
>>> print(expectlist)
[0, 1, 2, 3, 4]