tuple:(1,2) #上下方补行零,左右方补两行零
nn.zeroPad2d((1,2,1,2)) #左侧补一列,右侧补两列,上方补一行,下方补两行
def make_features(cfg: list): layers = [] in_channels = 3 for v in cfg: if v == "M": layers += [nn.MaxPool2d(kernel_size=2, stride=2)] else: conv2d = nn.Conv2d(in_channels, v, kernel_size=3, padding=1) layers += [conv2d, nn.ReLU(True)] in_channels = v return nn.Sequential(*layers) #非关键字参数传入
ceil_mode=True #向上取整
ceil_mode=False #向下取整