Pytorch--Tensor, Numpy--Array,Python--List 相互之间的转换
生活随笔
收集整理的這篇文章主要介紹了
Pytorch--Tensor, Numpy--Array,Python--List 相互之间的转换
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、 Python--List Numpy--Array
list = [[1, 2, 4, 8], [0.1, 0.4, 0.9, 0.8]] list_np = np.array(list) print('list_np的維度:',list_np.shape) print('list_np的類型:',type(list_np))運行結果:
2、Python--List Pytorch--Tensor
test = [[1, 2, 4, 8], [0.1, 0.4, 0.9, 0.8]] tensor_ = torch.Tensor(test) print('test的類型:', type(test)) print('tensor_的類型:', type(tensor_))運行結果&
總結
以上是生活随笔為你收集整理的Pytorch--Tensor, Numpy--Array,Python--List 相互之间的转换的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Pytorch 词嵌入word_embe
- 下一篇: python 加载mat文件