I want to stack a RGB images for 3D or 4D tensor

Hi, pytorch support teams.

I want to construct a 3D or 4D RGB tensor.
And, create a GAN model using these tensor.
How do I define how to create such a tensor?
I would like to stack the attached 2D RGB images.
Or can you extract each RGB element from a 3D image as a 3D tensor?

Kind regards,
yoshimura.

173480331-c74cf544-d349-4c10-a30e-d53735d7c00e

Typical CV image tensor has shape [channels, height, width] (channels = 3 for RGB). You could stack these with torch.stack(list_of_images, dim=-1), which gives a tensor of shape [channels, height, width, num_images].

Hi, HIkkei.

I could stack my data. Thanks’ your advice.