Solved by ptrblck in post #6 
              
              
                Assuming that each image tensor has the shape [channels, height, width], you could use expand or repeat to create a tensor with the shape [20, channels, height, width]: 
x = torch.randn(3, 224, 224)

x = x.unsqueeze(0)
x1 = x.expand(20, -1, -1, -1)
print(x1.shape)
> torch.Size([20, 3, 224, 224])

# …