How to change the tensor dimension in my net?

Hi,

I want to know how to change the tensor’s dimension in net.

self.net.add_module("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.

Thanks.

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