zhihou7 / BatchFormer

CVPR2022, BatchFormer: Learning to Explore Sample Relationships for Robust Representation Learning, https://arxiv.org/abs/2203.01522
242 stars 20 forks source link

batch_former_v2 issues #29

Closed thisisqiaoqiao closed 7 months ago

thisisqiaoqiao commented 7 months ago

Hello, B in shape (B, N, C) in the picture represents Batchsize. If so, when batch_first= False of TransformerEncoderLayer, the input and output should be (seq, batch, feature), but your code input The size is (batch, seq, feature)

image

zhihou7 commented 7 months ago

We treat the seq as the batch dimension, then we apply the batchformer along the original batch dimension (the first dimension ).

thisisqiaoqiao commented 7 months ago

Thank you for your reply. Can you explain in detail the meaning of N and C in (B, N, C)? Does the V2 version have one more batch dimension than the original version? Thank you very much.

image

thisisqiaoqiao commented 7 months ago

Is there a problem here? image

zhihou7 commented 7 months ago

It is right. N is the batch dimension. You will calculate bf along the first dimension.

thisisqiaoqiao commented 7 months ago

Thank you very much for your reply.