Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResNeSt的pytorch代码 #162

Open
lrfighting opened this issue Aug 16, 2021 · 5 comments
Open

ResNeSt的pytorch代码 #162

lrfighting opened this issue Aug 16, 2021 · 5 comments

Comments

@lrfighting
Copy link

请问有ResNeSt的pytorch网络结构的实现代码吗,我在哪里可以找到他们?

@lrfighting
Copy link
Author

https://github.com/zhanghang1989/ResNeSt/blob/master/resnest/torch/models/resnet.py
https://github.com/zhanghang1989/ResNeSt/blob/master/resnest/torch/models/resnest.py

好的,非常感谢,请问这个思想我可以应用于resnet18网络上吗,他会是有用的吗?还是他必须要在resnet50及以上?

@zhanghang1989
Copy link
Owner

应该是可以的

@Kingtin
Copy link

Kingtin commented Jan 17, 2022

我运行把模型拷贝过来后运行,提示错误。我并没有改动模块,这是哪里出问题了呢?
Traceback (most recent call last):
File "/Users/king/Code/IBRNet/ibrnet/resneSt.py", line 333, in
y = model(x)
File "/Users/king/Anaconda/anaconda3/envs/pxy/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/Users/king/Code/IBRNet/ibrnet/resneSt.py", line 304, in forward
x = self.layer1(x)
File "/Users/king/Anaconda/anaconda3/envs/pxy/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/Users/king/Anaconda/anaconda3/envs/pxy/lib/python3.6/site-packages/torch/nn/modules/container.py", line 139, in forward
input = module(input)
File "/Users/king/Anaconda/anaconda3/envs/pxy/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/Users/king/Code/IBRNet/ibrnet/resneSt.py", line 117, in forward
out = self.conv2(out)
File "/Users/king/Anaconda/anaconda3/envs/pxy/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/Users/king/Code/IBRNet/ibrnet/splat.py", line 72, in forward
gap = self.bn1(gap)
File "/Users/king/Anaconda/anaconda3/envs/pxy/lib/python3.6/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/Users/king/Anaconda/anaconda3/envs/pxy/lib/python3.6/site-packages/torch/nn/modules/batchnorm.py", line 178, in forward
self.eps,
File "/Users/king/Anaconda/anaconda3/envs/pxy/lib/python3.6/site-packages/torch/nn/functional.py", line 2279, in batch_norm
_verify_batch_size(input.size())
File "/Users/king/Anaconda/anaconda3/envs/pxy/lib/python3.6/site-packages/torch/nn/functional.py", line 2247, in _verify_batch_size
raise ValueError("Expected more than 1 value per channel when training, got input size {}".format(size))
ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 32, 1, 1])

@zhanghang1989
Copy link
Owner

这个问题是因为 batch size 是 1,这样做必须在 evaluation 的模式下,你可以在 forward 之前做 model.eval()

如果是 training mode,每个gpu 的 batch size 必须大于 1,否则 batch normalization 不发挥作用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants