Softmax in 3 D AssertionError: Softmax requires a 2D tensor as inputAssertionError: Softmax requires a 2D tensor as input

l have a variable preds :

preds.dim()
3
[torch.cuda.FloatTensor of size 26x1x37 (GPU 0)]

l want to apply softmax on this :
m=torch.nn.Softmax()

assert input.dim() == 2, 'Softmax requires a 2D tensor as input'

AssertionError: Softmax requires a 2D tensor as input

Do l have to change the dimension of my variable ?
if yes , how can l do that
26x1x37 to become 26x37

Thank you

Go through squeeze option to reduce the dimension:
http://pytorch.org/docs/master/torch.html?highlight=squeeze#torch.squeeze

1 Like

Thank you @pvskand it works

1 Like