import torch.nn as nn import torch # stride=2/4/8 分别生成20/12 10/6 5/3三种尺度的特征图 # 下采样倍率与stride的2的幂次方成正比 class Block(nn.Module): def __init__(self, in_channel, out_channel, stride=8, downsample=None, **kwargs): super(Block, self).__init__() self.conv1 = nn.Conv2d(in_channels=in_channel, out_channels=out_channel, kernel_size=3, stride=stride, padding=1, bias=False) self.bn1 = nn.BatchNorm2d(out_channel) self.relu = nn.ReLU() def forward(self, x): out = self.conv1(x) out = self.bn1(out) out = self.relu(out) return out from torchsummary import summary # 自己查看模型的架构 model = Block(in_channel=3, out_channel=64).cuda() # 输出前channel在前面 summary(model, (3, 40, 24))
下采样倍率与stride的2的幂次方成正比
最新推荐文章于 2024-09-01 00:45:39 发布