chenyuntc / pytorch-book

PyTorch tutorials and fun projects including neural talk, neural style, poem writing, anime generation (《深度学习框架PyTorch:入门与实战》)
MIT License
12.11k stars 3.74k forks source link

第四章resnet中的问题 #139

Open grandxin opened 5 years ago

grandxin commented 5 years ago

感谢作者的详细讲解!有两个问题希望了解一下:

  1. resnet的实现里: layers.append(ResidualBlock(inchannel, outchannel, stride, shortcut))

    for i in range(1, block_num):
        layers.append(ResidualBlock(outchannel, outchannel))
    return nn.Sequential(*layers)

这里在循环内部为啥没有shortcut? 看resnet的原图似乎每个block都有shortcut的啊。

  1. residual block的实现里: def forward(self, x): out = self.left(x) residual = x if self.right is None else self.right(x) out += residual return F.relu(out) 这里命名建议改一下哈。left才是真正的residual, 而不是right中的shortcut部分。