akore128
akore128

Reputation: 79

torchvision make_grid only displays top image

For some reason make_grid only displays the top image of the tensor decoded_samples. I can confirm that all of the decoded_samples have different values.
Moreover, when an individual image is passed (eg. make_grid(decoded_samples[3]), it is properly displayed.
Why is this happening?

samples = torch.randn(64, 32).to(device)
decoded_samples = model.decoder(samples).view(64,1,28,28)
fig = plt.figure(figsize = (10, 10))   
ax1 = plt.subplot(111)
ax1.imshow(torchvision.utils.make_grid(decoded_samples[:16], nrow=4, pad_value=1.)\
                .data.cpu().numpy().transpose(1, 2, 0), cmap='gray')
plt.show()

enter image description here

Upvotes: 0

Views: 180

Answers (1)

akore128
akore128

Reputation: 79

There's no discernible reason as to why this code doesn't work. Moving the code onto a Colab notebook produced the correct results...

Upvotes: 0

Related Questions