torch.nn.Conv2d()函数详解

import torch

x = torch.randn(2,1,7,3)
conv = torch.nn.Conv2d(1,8,(2,3))
res = conv(x)

print(res.shape)    # shape = (2, 8, 6, 1)
输入:

x
[ batch_size, channels, height_1, width_1 ]
batch_size 一个batch中样例的个数       2
channels 通道数,也就是当前层的深度 1
height_1, 图片的高                                 7
width_1, 图片的宽                                  3

Conv2d的参数
[ channels, output, height_2, width_2 ]

channels, 通道数,和上面保持一致,也就是当前层的深度  1
output 输出的深度                                                                 8
height_2, 过滤器filter的高                                                      2
width_2, 过滤器filter的宽                                                       3

输出:

res
[ batch_size,output, height_3, width_3 ]

batch_size, 一个batch中样例的个数,同上           2
output 输出的深度                                                  8
height_3, 卷积结果的高度                                      6 = height_1 - height_2 + 1 = 7-2+1
width_3, 卷积结果的宽度                                       1 = width_1 - width_2 +1 = 3-3+1

参考
torch.nn.Conv2d
torch.nn.MaxPool2d

  • 49
    点赞
  • 105
    收藏
    觉得还不错? 一键收藏
  • 14
    评论
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值