Plotting multiple tensors

Hello Pytorch community :slight_smile:

I have a question about drawing/plotting a group of images tensors.

So if I had a combined tensor that has 5 different tensors (each time I add one by one to it using, Y)))

And I want to plot it like one beside of each other (like one row of 5 columns)

What I tried is first to plot just one image in order just to see it but I had an error of TypeError: Invalid shape (8, 1, 28, 28) for image data where [8, 1, 28, 28] is the shape of one tensor image

And about plotting them all together, I thought of maybe using:

poly.subplots(something here)
make_grid(combined tensor or other things)

But still, I’m not fully convinced about how I can do it.

Any help please with that?

That isn’t really a good idea to do at scale. It’s better to keep a list and cat at the end.

Another thing: Isn’t that a batch of 8 images rather than one?

I use pyplot.imshow a lot, it wants HWC format (and not batch), so you would need to do something like combined = combined.permute(0, 2, 3, 1).reshape(-1, combined.size(3), combined.size(1)) (or permute(2, 0, 3, 1).reshape(combined.size(2, -1, combined.size(1).

torchvision has make_grid that can do the layout for you more easily than the above.

Best regards