Sandy-Zeng / NPAttack

Pytorch implementation of NPAttack
11 stars 2 forks source link

Some questions about the self_attention module #3

Open Dirt0591 opened 3 years ago

Dirt0591 commented 3 years ago

Why are q_conv, k_conv, v_conv in self_attention module redefined during each forward of the model? Why implement rep = rep.view(m_batchsize, width_height, C) after rep = torch.bmm(v, attention.permute(0, 2, 1))? It seems that the shape of tensor rep has already satisfied the calculation?

Sandy-Zeng commented 3 years ago

Thanks for your careful inspection. We follow the implement of NP model as https://github.com/geniki/neural-processes/blob/master/main.py. According to your reminder, we reviewed our code and found that this is a mistake by redefining q_conv, k_conv, v_conv in self_attention module during each forward of the module. Actually, the parameters of the self attention module are not fully trained, you can regard our implement as the original NP without attention. Sorry for the mistake, however, the attention module will not affect our black box attacks algorithm.

The implement of rep = rep.view(m_batchsize, width_height, C) is just to check the dimension of the tensor satisfied the calculation.