Hi Taran!



 TaranRai:

With a batch size of 5, I have created tensors of:
torch.Size([5, 2048, 1, 1])

I’m not really sure what to do if I want to feed this into a simple autoencoder. Would anyone be able to clarify how I should reshape this tensor to feed into an nn.linear layer?


I assume that your problem is the last two length-1 dimensions
of your tensor.  If so, you can use torch.squeeze() 17 to get rid of
them.
You could then feed your (now torch.Size([5, 2048]))
tensor to, for example, a nn.Linear (2048, 256) layer.
(Note, if you ever have a batch size of 1, this will break by also
killing off the batch-size dimension.  In such a case, you would
have to use torch.squeeze()'s dim argument to specify the
length-1 dimensions your need to get rid of.)
Good luck.
K. Frank