Open Hompeaz opened 1 month ago
@Hompeaz You're correct that last_block_dim != planes * block.expansion
is the right comparison. However, this doesn't affect the functionality of ResNet-18. The condition is actually redundant because the first term, stride != 1
, already fully handles the relevant cases for whether the if-block should be skipped or not.
I left the term in to maintain consistency with the official PyTorch ResNet implementation (which includes networks with more than 18 layers).
Thanks for the notice, but I'm not sure the issue title "Tensor size mismatch issue in resnet decoder" is actually relevant to your comment.
Thanks for the response. Sorry I didn't write clearly. For "Tensor size mismatch issue": I was testing your autoencoder using CIFAR10 ( 32x32 pixel images ). The tensor output of layer1 in the decoder have 64 channels, but "de_conv1" expect 32 channel. So I look into the code and find this issue. If I change the last_block_dim
to 32, it will cause another tensor size mismatch at line 76: https://github.com/eleannavali/resnet-18-autoencoder/blob/main/src/classes/resnet_using_basic_block_decoder.py#L76, where the identity have 64 channels and output have 32 channels. So I look into the code, and find the issue. If I don't change the condition self.inplanes != planes * block.expansion
, there will be no upsample which will cause the tensor size mismatch.
I think at line 164 the resnet decoder (https://github.com/eleannavali/resnet-18-autoencoder/blob/main/src/classes/resnet_using_basic_block_decoder.py#L164), the condition
self.inplanes != planes * block.expansion
is supposed to belast_block_dim != planes * block.expansion
.