Pytorch Code Snippet

Visualization

Making Image Grid

def imshow(img):
    npimg = img.numpy() 
    plt.imshow(np.transpose(npimg, (1, 2, 0))) # Numpy is H x W x C 


# get some random training images
dataiter = iter(trainloader)
images, labels = next(dataiter)

# show images
imshow(torchvision.utils.make_grid(images))

MISC

# set seed
torch.manual_seed(1729)

Last updated