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

ERF is smaller after changing the input image size #25

Open
sleepat-11 opened this issue May 10, 2022 · 6 comments
Open

ERF is smaller after changing the input image size #25

sleepat-11 opened this issue May 10, 2022 · 6 comments

Comments

@sleepat-11
Copy link

i changed the input size to 224×224,and compare RepLKNet with resnet101, it seems that resnet101 is larger than RepLKNet-13,
left is RepLKNet-13, right is resnet101

13_224resnet224

@DingXiaoH
Copy link
Owner

Hi, thanks for sharing the results. We would appreciate it if you could provide more details. For example, which weights have you loaded?

@sleepat-11
Copy link
Author

sleepat-11 commented May 27, 2022

Hi, thanks for sharing the results. We would appreciate it if you could provide more details. For example, which weights have you loaded?

Hi,thanks for reply. i followed the instruction in README.md, loaded the weights of RepLKNet-13 provided by this link. Resnet101 model is downloaded from torchvision.

Then i modify the code line

transforms.Resize((1024, 1024), interpolation=Image.BICUBIC),

to transforms.Resize((224,224),interpolation=Image.BICUBIC)
here is the input image used (if it is needed)
code:qrgb

@firrice
Copy link

firrice commented Oct 6, 2022

Hi, thanks for sharing the results. We would appreciate it if you could provide more details. For example, which weights have you loaded?

Hi,thanks for reply. i followed the instruction in README.md, loaded the weights of RepLKNet-13 provided by this link. Resnet101 model is downloaded from torchvision.

Then i modify the code line

transforms.Resize((1024, 1024), interpolation=Image.BICUBIC),

to transforms.Resize((224,224),interpolation=Image.BICUBIC) here is the input image used (if it is needed) code:qrgb

Hi, I meet the similar problem, the only differencve is that i use RepLKNet-31B rather than RepLKNet-13. It also seems that resnet101 is larger than RepLKNet-31B when input size is set to be 224, above is RepLKNet-31B, below is resnet101.
replknet31_224_visual
resnet101_224_visual
Except for the problem, i observe the other phenomenon. When we use the model which is initialized by default rather than by pretrained on ImageNet-1K, its ERF is visualized as below(input size is set to 1024):
replknet31_nopre_1024_visual
The visual result which use the pretrained model on ImageNet can bee seen below:
replknet31_1024_visual
We can see that ERF is very small when the model is initialized by default, and if it is a kind of unreasonable initial bias? More over,if the initialization will bring difficulties durging learning?
(All code follows the instruction in README.md)

@DingXiaoH
Copy link
Owner

Hi, I think the image size is too small (but downstream tasks usually use much higher resolutions) so that every model's ERF can cover the whole image. In this case, the definition of ERF intuitively changes from "which part can the model see" to "in the region the model can see, which part does it mostly attend to". And in this case, the contribution scores have low variance and the normalization will make the ERF map look unnatural.

@firrice
Copy link

firrice commented Oct 9, 2022

Hi, I think the image size is too small (but downstream tasks usually use much higher resolutions) so that every model's ERF can cover the whole image. In this case, the definition of ERF intuitively changes from "which part can the model see" to "in the region the model can see, which part does it mostly attend to". And in this case, the contribution scores have low variance and the normalization will make the ERF map look unnatural.

Thanks so much! It really helps me understand it.

@ratom
Copy link

ratom commented Aug 6, 2023

I tried to view the effective receptive field, but when I used this !python erf/visualize_erf.py --model resnet101 --data_path /path/to/imagenet-1k --save_path resnet101_erf_matrix.npy
I got this error
Traceback (most recent call last):
File "/content/RepLKNet-pytorch/erf/visualize_erf.py", line 15, in
from erf.resnet_for_erf import resnet101, resnet152
ModuleNotFoundError: No module named 'erf'

Moreover, this code is very complex. If I want to visualize the erf for my custom model, how can I use this? My model combines CNN and transformer, but this code is very complex to understand and use by early learners like me. Maybe this code is suitable for experts. It could be great if you shared your knowledge and great work that can be understandable by basic learners like me.

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

4 participants