filipradenovic/cnnimageretrieval-pytorch

some questions about rmac pooling method

Julymycin opened this issue · 2 comments

hello,
firstly, your codes really help me a lot, thanks!
nowadays i am trying to use rmac pooling method to get images' feature vectors from [N, channels, W, H] feature maps, but i got some questions.

`W = x.size(3)
H = x.size(2)

w = min(W, H)
w2 = math.floor(w/2.0 - 1)

b = (max(H, W)-w)/(steps-1)
(tmp, idx) = torch.min(torch.abs(((w**2 - w*b)/w**2)-ovr), 0) # steps(idx) regions for long dimension

# region overplus per dimension
Wd = 0;
Hd = 0;
if H < W:  
    Wd = idx.item() + 1
elif H > W:
    Hd = idx.item() + 1`

if W==H in my feature maps, codes above seems not work, does it matters?

It should work even for W == H, not sure if that is the problem. I haven't used rmac pooling in a long time, as we added roipool which is a generalization, it does regional pooling using any given pooling operator, ie spoc, mac, gem, etc.

You can use it by adding --regional frag in the example training script. To see how a generic regional pooling network is initialized, take a look at imageretrievalnet.py#L212. Also, take a look at the Rpool layer.

thx : )