EADST

Convert Paddle Tensor to Numpy to List

Convert Paddle Tensor to Numpy to List

import cv2
import numpy
import paddle

# load an image
im = cv2.imread("test.jpg")
print(type(im)) # 

# numpy to tensor
tensor_data = paddle.to_tensor(data) 
print(type(tensor_data)) # 

# tensor to numpy
numpy_data = tensor_data.numpy() 
print(type(numpy_data)) # 

# numpy to list
list_data = numpy_data.tolist()
print(type(list_data)) # 

# tensor to list
tlist_data = tensor_data.tolist()
print(type(tlist_data)) # 

# list to tensor
ltensor_data = paddle.to_tensor(tlist_data) 
print(type(ltensor_data)) # 

# list to numpy
lnumpy_data = np.array(list_data)
print(type(lnumpy_data)) # 
相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
站点统计

本站现有博文266篇,共被浏览440568

本站已经建立2019天!

热门文章
文章归档
回到顶部