Could you print the shape of the tensor you are passing to F.softmax?
It seems dim2 is just missing. Are you adding the batch dimension to your data in the test case? This is often forgotten and yields these kind of errors.
You can call functions like softmax on “negative” dimensions to use reverse indices just like with python lists. -1 for example would be the last dimension.
The difference between nn.Softmax and F.softmax is not that big, as neither has any parameters stored. While nn.Softmax is an nn.Module and must therefore be initialized, F.softmax is just the functional API equivalent.