Display image svhn


I am working with svhn and I have realized there is a problem with how should I display an image. Using a torchvision dataloader i sample an image x. I am getting different results when plotting. I know I should I convert to numpy and use matplot lib. This library expects the numpy array to have dimension (H,W,C) height width channel, but pytorch is (C,H,W), I think. So to plot I can do either

x=x.numpy() x=np.tranpose(x,(1,2,0)) plot(x)
or I can do
x=x.view(1,2,0).numpy() plot(x)

However I do not get the expected results. What is happening? How does really pytorch manage memory?


You don’t want .view(1,2,0) - that works like np.reshape
Try this


thanks, it seems that the doc of permute is not available and so I though everything was done with view


Some docs from master seem to be broken at the moment.
You could have a look at the permute doc from 0.3.1.

1 Like