Make_grid with unequal grid?

I can use make_grid fine to make such a grid:


But how can I make a grid like this:

Ideally I would like to have the images in each grid padded randomly with different values.

Thank you.

You could probably use matplotlib.gridspec for it.
I don’t think this will pad your inputs, so you might need to add the padding in PyTorch or numpy.

Thanks that’s a nice suggestion.