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

请问一下这个模块在分割的时候如何设置dct_h和dct_w? #24

Open
nnoyuwan opened this issue Oct 19, 2021 · 2 comments
Open

Comments

@nnoyuwan
Copy link

nnoyuwan commented Oct 19, 2021

输入要经过下采样和上采样,输入图片也就需要缩小和放大好几次,那我是不是要在__init__就把input size传进去,有什么办法能实时获取输入大小吗?

我有尝试在forward函数里获取x的大小,但后面训练很慢,我就意识到dct应该需要在搭建网络时预生成。

@cfzd
Copy link
Owner

cfzd commented Oct 20, 2021

@nnoyuwan
我们在检测的模型中考虑到了这个问题,其实这个大小只是一个“参考大小”,并不一定是要和输入一样的。具体的代码可以看这个地方:

FcaNet/model/layer.py

Lines 54 to 55 in aa5fb63

if h != self.dct_h or w != self.dct_w:
x_pooled = torch.nn.functional.adaptive_avg_pool2d(x, (self.dct_h, self.dct_w))

如果输入大小和DCT大小不一样的话,我们会先做个resize然后在提取DCT频谱,而且resize只对应提取频谱,不会对输入特征造成任何影响。

其实也有个简单的办法,你可以把所有的dct_w和dct_h统统都设置为7,不用考虑输入大小的问题。

@nnoyuwan
Copy link
Author

谢谢

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

2 participants