美文网首页
Pytorch代码中的一些问题

Pytorch代码中的一些问题

作者: 吱吱加油 | 来源:发表于2020-04-08 22:38 被阅读0次

torch.nn.Conv3D

(in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=False)

in_planes输入通道数

out_planes输出通道

kernel_size卷积核,当只是等于3时,说明卷积核为3*3*3,其中当其为(2,1,1)说明其为1*1*2的卷积核

stride:表示步长,其也为3维数据,与kernel_size相同

padding:表示补零行数(列数、高数),其也为3维数据

bias:表示偏置

以上均为自己理解


关于Pytorch中autograd中Variable属性与方法详见

『PyTorch』第五弹_深入理解autograd_上:Variable属性方法 - 叠加态的猫 - 博客园


from torch.nn import functionalas F
a=torch.rand(3,4)

print(a)

b=F.softmax(a,dim=0)#按列求和为1

print("hhhhhh,你说了:\n",b)

c=F.softmax(a,dim=1)#按行求和为1

print("hhhhhh,你说呢:\n",c)

result:

tensor([[0.4602, 0.9997, 0.4703, 0.5524],

        [0.5374, 0.8700, 0.9057, 0.1282],

        [0.3672, 0.9267, 0.9170, 0.9059]])

hhhhhh,你说了:

tensor([[0.3343, 0.3561, 0.2434, 0.3248],

        [0.3611, 0.3128, 0.3762, 0.2125],

        [0.3046, 0.3310, 0.3805, 0.4626]])

hhhhhh,你说呢:

tensor([[0.2074, 0.3557, 0.2095, 0.2274],

        [0.2220, 0.3096, 0.3209, 0.1475],

        [0.1614, 0.2824, 0.2797, 0.2766]])


相关文章

网友评论

      本文标题:Pytorch代码中的一些问题

      本文链接:https://www.haomeiwen.com/subject/jjcfmhtx.html