RepLKNet-pytorch icon indicating copy to clipboard operation
RepLKNet-pytorch copied to clipboard

ERF is smaller after changing the input image size

Open sleepat-11 opened this issue 2 years ago • 6 comments

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

sleepat-11 avatar May 10 '22 12:05 sleepat-11

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

DingXiaoH avatar May 26 '22 16:05 DingXiaoH

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 https://github.com/DingXiaoH/RepLKNet-pytorch/blob/2b8b6c67a3455dd5ae951ea682269fbca8aff9f2/erf/visualize_erf.py#L46

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

sleepat-11 avatar May 27 '22 10:05 sleepat-11

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

https://github.com/DingXiaoH/RepLKNet-pytorch/blob/2b8b6c67a3455dd5ae951ea682269fbca8aff9f2/erf/visualize_erf.py#L46

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)

firrice avatar Oct 06 '22 02:10 firrice

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.

DingXiaoH avatar Oct 09 '22 03:10 DingXiaoH

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.

firrice avatar Oct 09 '22 05:10 firrice

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.

ratom avatar Aug 06 '23 02:08 ratom