Torch.cat Sizes of tensors must match except in dimension 2. Got 400 and 100 (The offending index is 0)

I have two tensors, one is shaped (1,1,100) and another (1,1,400)

inside forward() method of my model they get .cat() together, but for some reason it throws this error:

Sizes of tensors must match except in dimension 2. Got 400 and 100 (The offending index is 0)

What is the reason???

Code:

def forward(self, cond, hidden,state):
    '''
    Cond shape: (batch,1,100)

    hidden and state shape: (batch,1,400)
    '''
    cond = torch.cat((cond,hidden),1) #Error is here
    . . .
1 Like

Fixed itself, change 1 to 2 in torch.cat()

1 Like