pytorch
Env1sage
分享自己的学习经验和内容
展开
-
pytorch学习 API文档 传送接口
pytorch自学经验原创 2022-07-07 22:10:28 · 542 阅读 · 0 评论 -
pytorch 学习笔记——维度变换
view/reshapeIn [13]: a=torch.rand(4,1,28,28)In [14]: a.shapeOut[14]: torch.Size([4, 1, 28, 28])In [15]: a.view(4, 28*28)Out[15]: tensor([[0.9020, 0.5015, 0.1010, ..., 0.4946, 0.1665, 0.5352], [0.3386, 0.5002, 0.7858, ..., 0.1595, 0.9348, 0.3489]原创 2022-05-14 20:39:15 · 511 阅读 · 0 评论 -
pytorch 学习笔记——索引与切片
索引In [130]:a=torch.rand(4,3,28,28)In [131]: a[0].shape0ut[131]: torch.Size([3, 28, 28])In [138]: a[0,0].shape0ut[138]: torch.Size([28, 28])In [139]: a[0,0,2,4]0ut[139]: tensor(0. 8082)前/后N项In [140]: a.shape0ut[140]: torch.Size([4, 3, 28, 28])原创 2022-05-13 21:29:29 · 608 阅读 · 0 评论 -
pytorch 学习笔记——初始化和创建变量
创建Tensor从numpy导入In [62]: a=np.array([2,3.3])In [63]: torch.from_numpy(a)0ut[63]: tensor([2.0000, 3.3000], dtype=torch.float64)//从NUMPY导入的FLOAT其实是DOUBLE类型In [65]: a=np.ones([2,3])In [66]: torch.from_numpy(a)0ut[66]:tensor([[1.,1.],[1., 1.,1.]],dty原创 2022-05-11 20:34:18 · 846 阅读 · 0 评论 -
pytorch中没有string数据类型的处理
One-hot使用one-hot编码对单词进行编码(适用于有限且少量词库的数据)one-hot对英文字母编码(仅26维向量)Embeddingword2vecglove解决“i dislike”和“i like”之间单词相关性和类似中文汉字较多的数据问题...原创 2022-05-09 22:13:18 · 515 阅读 · 0 评论 -
pytorch 学习笔记——变量和数据类型
检查变量类型a.type()type(a)isinstance(a,torch.FloatTensor)//True同一个tensor部署在CPU和GPU上是不同的In [21]: isinstance( data, torch. cuda . DoubleTensor )0ut[21]: FalseIn [22]: data=data. cuda( )//将数据搬运到cuda上面In [23]: isinstance( data, torch. cuda . DoubleTenso原创 2022-05-10 20:55:09 · 334 阅读 · 0 评论