![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Pytorch
@江上雨
这个作者很懒,什么都没留下…
展开
-
安装torch_scatter,torch-sparse,torch-cluster,torch-spline-conv,torch-geometric
安装torch_scatter,torch-sparse,torch-cluster,torch-spline-conv,torch-geometric转载 2021-03-17 11:35:18 · 367 阅读 · 0 评论 -
关于多分类问题的输出与标签对应问题
import torchdef accuracy(y_hat, y): return (y_hat.argmax(dim=1) == y).float().mean().item()x = torch.tensor([[0,1],[1,0],[0,1]])label = torch.tensor([1,0,1])#label = torch.tensor([[1],[0],[0]]) #用这个会发生广播print(x.argmax(dim=1))print(x.argmax(dim=1原创 2020-10-17 19:40:24 · 629 阅读 · 0 评论 -
python切片记录
import numpy as npimport torchfrom torch.autograd import Variable import numpy as npimport torchfrom torch.autograd import Variable x = Variable(torch.rand(5,5),requires_grad = False)print(x)print(x[:,0:1])print(x[:,4:5])print(x[:,4])print(x[:原创 2020-10-14 20:32:29 · 135 阅读 · 0 评论 -
pytorch之stack
a1 = torch.arange(4).view(2,2)a2 = torch.arange(4,8).view(2,2)print(a1)print(a2)print(torch.stack([a1,a2],dim=0))print(torch.stack([a1,a2],dim=1))print(torch.stack([a1,a2],dim=2))#输出'''tensor([[0, 1], [2, 3]])tensor([[4, 5], [6, 7原创 2020-08-23 12:12:07 · 1457 阅读 · 0 评论 -
填充和步幅
https://blog.csdn.net/dongyunchao123/article/details/100549164转载 2020-08-23 11:13:08 · 128 阅读 · 0 评论 -
torch的运算
###加法X = torch.ones(2,2)Y = torch.tensor([1,3]) #触发广播机制,第一行复制到第二行后在与X相加#Y = torch.tensor([[1,3]])#触发广播机制,第一行复制到第二行后在与X相加#Y = torch.tensor([[1],[3]])#触发广播机制,第一列复制到第二列后在与X相加print(X + Y)print(X.add(Y))print(torch.add(X,Y))#输出'''tensor([[2., 4.],原创 2020-08-23 10:15:16 · 1835 阅读 · 0 评论 -
关于tensor中数值类型
X = torch.tensor([[1,2],[3,4]])#查看X的类型print(type(X))#查看数据值的类型 print(X.dtype)#X的数据类型为torch.int64,因为输入的数据全为整数Y1 = torch.ones(2,2)Y2 = torch.zeros(2,2)Y3 = torch.randn(2,2)#Y1、Y2、Y3的数据类型为torch.float32,torch自带的定义张量方式指均为float型...原创 2020-08-23 09:41:10 · 1000 阅读 · 0 评论 -
pytorch填坑之路
1、pytorch版本要与CUDA版本对应CUDA版本Pytorch版本7.50.4.1 ,0.3.0, 0.2.0,0.1.12-0.1.68.01.0.0 ,0.4.19.01.1.0,1.0.1, 1.0.0,0.4.19.21.6.0,1.5.0,1.4.0,1.2.0,0.4.110.01.2.0,1.1.0,1.0.1 ,1.0.010.11.6.0,1.5.0, 1.4.0 ,1.3.010.21.6.0,1.5.0原创 2020-08-19 23:21:57 · 166 阅读 · 0 评论