-
-
Save Sanlap1997/0b93f0a8844f4ec6b97a5e08115e64bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# show random images from training set | |
cols = 8 # Number of columns | |
rows = 4 # Number of rows | |
fig = plt.figure(figsize=(2 * cols, 2 * rows)) | |
# Add subplot for each random image | |
for col in range(cols): | |
for row in range(rows): | |
random_index = np.random.randint(0, len(Y_train)) # Pick a random index for sampling the image | |
ax = fig.add_subplot(rows, cols, col * rows + row + 1) # Add a sub-plot at (row, col) | |
ax.grid(b=False) # Get rid of the grids | |
ax.axis("off") # Get rid of the axis | |
ax.imshow(X_train[random_index, :]) # Show random image | |
ax.set_title(CIFAR10_CLASSES[Y_train[random_index][0]]) # Set title of the sub-plot | |
plt.show() # Show the image |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment