TransFG icon indicating copy to clipboard operation
TransFG copied to clipboard

About part_inx in part select module

Open haoweiz23 opened this issue 4 years ago • 3 comments

https://github.com/TACJu/TransFG/blob/ff28b5842fe41dbbb03a3cf698888dd57c882b8a/models/modeling.py#L266

Why part_inx variable need to plus 1?

haoweiz23 avatar Apr 22 '21 06:04 haoweiz23

maybe because index 0 is CLS token?

ludics avatar Apr 22 '21 09:04 ludics

maybe because index 0 is CLS token?

I think so. You probably found this line that last_map = last_map[:, :, 0, 1:] in class Part_Attention. So, when I canceled the class token and fixed that code to last_map = last_map[:, :, 0], some errors happened. After I Annotated part_inx = part_inx + 1, it had been fixed.

xuritian317 avatar Nov 11 '21 08:11 xuritian317

last_map = last_map[:,:,0,1:] _, max_inx = last_map.max(2) The max_inx start from 0 because of .max() but actually we skip the first element (1:). So, when project back to the original tensor, we need to + 1 to the indexes.

vietth-bka avatar Jul 22 '22 10:07 vietth-bka