The problem now is that each batch has dimension (batchsize, 1, H, W).
For all batches, I would like to have the dimension (batchsize, H*W). Is there a simple way to use transforms to do this?
That’s how I do it right now, but it strikes me as very inefficient as I have to do this each time my Dataloader hands me a new batch. I was hoping there is a preprocessing solution so that my Dataloader hands me the batches in the correct shape (no more reshaping during training).
You can also do the reshape in your dataloader if you think that is a significant source of inefficiency. However, this is unlikely because a reshape doesn’t actually change the data layout or require any copying of data. It just changes the strides for indexing.
Alright, then it might not be computationally inefficient, but it would help readability if I could tell the dataloader from the get go what to do. How do I do it in the Dataloader? The Dataloader is not a simple tensor.