How to change the tensor dimension in my net?


I want to know how to change the tensor’s dimension in net."out1", nn.softmax(dim=1)

and I got a tensor[ 1681, 1, 1 ] from output.But I want to change it into tensor[ 41, 41, 1, 1 ].
Can someone please give me some advice.


Hi, you can change its shape with the view command. new_tensor = tensor.view(41, 41, 1, 1). If you want to do this within the network, do that in the forward function

1 Like