Pre-Activation ResNet (ResNet-V2) implementation error leads to NaN loss
Author: htwang14Created Jun 22, 2021Updated Dec 2, 2022
Hi Kuang,
I think a batch normalization is missing after the last residual block and before the pooling/fully connected layer in the current pre-activation resnet implementation.
There should be something like out = F.relu(self.bn(out), inplace=True) inserted there, where self.bn = nn.BatchNorm2d(512) should be define in the __init__ function, as done in other public implementations such as this one.
The current Pre-activation resnet cannot converge on CIFAR10. I tried SGD optimizer with initial learning rate 0.1 on pre-act resnet18. The loss soon goes to NaN after the first several iterations.
Fixing the codes in my proposed way leads to good convergence.
:-)
Thanks, Haotao
Source: kuangliu/pytorch-cifar