a = torch.zeros((1,1,100))
a.expand(1,2,100)
Works
a = torch.zeros((1,2,100))
a.expand(1,4,100) gives error
RuntimeError: The expanded size of the tensor (4) must match the existing size (2) at non-singleton dimension 1
Why is this?
Also i am trying to do batched beam search, my batch size=2 and beam size=2. When it comes out from encoder, hidden dimension is 1x2x100 [as i dont consider beam there]. Now as it has to be fed into the decoder with two initial states for two sentences, i need to make it 1x4x100. Is the approach right?