博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Torch和Numpy——查看形状类型
阅读量:551 次
发布时间:2019-03-09

本文共 650 字,大约阅读时间需要 2 分钟。

输入

import numpy as npimport torcha = np.array([[1,2],[3,4]])print(a.shape,np.shape(a),a.dtype)print('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')a = a.astype(np.float32)print(a.dtype)print('***************************************************')b = torch.tensor([[1,2],[3,4]])print(b.shape,b.size(),b.type())print("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")b = b.float()print(b.dtype)

输出

(2, 2) (2, 2) int32@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@float32***************************************************torch.Size([2, 2]) torch.Size([2, 2]) torch.LongTensor&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&torch.float32

 

转载地址:http://mdypz.baihongyu.com/

你可能感兴趣的文章