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

Does AdaPool2d's beta require fixed image size? #5

Closed
johnanthonyjose opened this issue Dec 7, 2021 · 1 comment
Closed

Does AdaPool2d's beta require fixed image size? #5

johnanthonyjose opened this issue Dec 7, 2021 · 1 comment

Comments

@johnanthonyjose
Copy link

I'm currently running AdaPool2d as a replacement of MaxPool2d in Resnet's stem similar on how you did it in SoftPool. However, I keep on getting an assertionError in line 1325 as shown below:

assert isinstance(beta, tuple) or torch.is_tensor(beta), 'Agument `beta` can only be initialized with Tuple or Tensor type objects and should correspond to size (oH, oW)'

Does this mean beta requires a fixed image size, e.g. (224,244)? Or is there a way to make it adaptive across varying image size (e.g. object detection)?

@alexandrosstergiou
Copy link
Owner

alexandrosstergiou commented Dec 7, 2021

Hi @johnanthonyjose ,

The primary intention of beta (based also on the subsequent paper) was to use it as a regional-specific mask. So it should have the same size as the output tensor post-pooling (e.g. oH,oW).

However, if you expect to have inputs of different sizes, a way around this is to pass a Tuple or Tensor of size 1. This will essentially apply the same beta over the entire image. Although you lose the region-specific nature of the method, from some testing in my own projects, the difference in accuracy is not large.

So there are multiple ways to define beta, e.g.:

pool_2d_single = AdaPool2d(beta=(1,1)) # single beta param
pool_2d_mask = AdaPool2d(beta=(oH,oW)) # beta mask of oH x oW

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