ResNeSt icon indicating copy to clipboard operation
ResNeSt copied to clipboard

why the output of resnest.py only has 2 dimension?

Open chnzhero opened this issue 3 years ago • 2 comments

hi there, I've run your code resnest.py, and I got the result which is like that: torch.Size([3, 1000]) And I have a question: resnest is a backbone, so I think the output should be feature map looks like [H, W, C] I have no idea about such a situation, hoping your help :)

chnzhero avatar Dec 21 '21 09:12 chnzhero

Hello. ResNeSt is a model which achieved good results as the backbone for some transfer learning benchmarks but also evaluated on ImageNet classification (Sec. 5 in the paper). My implementation is a classifier (defaults to 1000 classes) and therefore the output has only two dimension. If you want the activation of the last bottleneck block, you can simply redefine the classifier attr of the model to nn.Identity():

import torch
import torch.nn as nn
from resnest.resnest import ResNeSt

resnest50 = ResNeSt([3, 4, 6, 3])
resnest50.classifier = nn.Identity()

img = torch.randn(3, 3, 224, 224)
print(resnest50(img).size())
# >>> torch.Size([3, C, H, W])

Anyway, I highly recommend using the official implementation if you are thinking to use ResNeSt. It's also in PyTorch hub. Their implementation is more stable than mine and provides pre-trained models. Also, I haven't maintained this repository for a while...

Hope this helps!

STomoya avatar Dec 21 '21 15:12 STomoya

Hello. ResNeSt is a model which achieved good results as the backbone for some transfer learning benchmarks but also evaluated on ImageNet classification (Sec. 5 in the paper). My implementation is a classifier (defaults to 1000 classes) and therefore the output has only two dimension. If you want the activation of the last bottleneck block, you can simply redefine the classifier attr of the model to nn.Identity():

import torch
import torch.nn as nn
from resnest.resnest import ResNeSt

resnest50 = ResNeSt([3, 4, 6, 3])
resnest50.classifier = nn.Identity()

img = torch.randn(3, 3, 224, 224)
print(resnest50(img).size())
# >>> torch.Size([3, C, H, W])

Anyway, I highly recommend using the official implementation if you are thinking to use ResNeSt. It's also in PyTorch hub. Their implementation is more stable than mine and provides pre-trained models. Also, I haven't maintained this repository for a while...

Hope this helps!

Hello, Thanks for your notice, I was too careless I havent try official version due to my poor ability, and I'll try it

thanks~

chnzhero avatar Dec 23 '21 08:12 chnzhero