galsang / BiDAF-pytorch

Re-implementation of BiDAF(Bidirectional Attention Flow for Machine Comprehension, Minjoon Seo et al., ICLR 2017) on PyTorch.
244 stars 85 forks source link

Fix a bug when batch_size = 1 #26

Closed Smlight closed 2 years ago

Smlight commented 4 years ago

Like the last comment in #12 .

If we grub a batch whose size equals to 1, the .squeeze() would lead to the loss of the first dimension. The simple but robust way to overcome this is to replace all .squeeze() with .squeeze(dim)