Does AdaPool2d's beta require fixed image size?
johnanthonyjose opened this issue · 1 comments
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)?
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