Skip to content

Instantly share code, notes, and snippets.

@erykml
Created January 25, 2019 21:48
Show Gist options
  • Save erykml/1756b68220693b061aac8a6b3f86f1c5 to your computer and use it in GitHub Desktop.
Save erykml/1756b68220693b061aac8a6b3f86f1c5 to your computer and use it in GitHub Desktop.
# inspect loaded images ----
# obtain one batch of training images
dataiter = iter(train_loader)
data, target = dataiter.next()
data = data.numpy() # convert images to numpy for display
# plot the images in the batch, along with the corresponding labels
fig = plt.figure(figsize=(20, 10))
# display 10 images
for idx in np.arange(10):
ax = fig.add_subplot(2, 10/2, idx+1, xticks=[], yticks=[])
imshow(data[idx])
ax.set_title(classes[target[idx]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment