Skip to content

Instantly share code, notes, and snippets.

@afozbek
Created January 28, 2019 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afozbek/285477fa587ac7c8126ea65831a419ea to your computer and use it in GitHub Desktop.
Save afozbek/285477fa587ac7c8126ea65831a419ea to your computer and use it in GitHub Desktop.
medium
num_of_samples = []
cols = 5 #We will select 5 random images
num_of_classes = 10 #each digit total: 10
fig, axs = plt.subplots(nrows=num_of_classes, ncols=cols,
figsize=(5, 10))
fig.tight_layout()
for i in range(cols):
for j in range(num_of_classes):
x_selected = X_train[y_train == j]
axs[j][i].imshow(x_selected[random.randint(0, len(x_selected -1)),
:, :],
cmap=plt.get_cmap('gray'))
axs[j][i].axis("off")
if i==2:
axs[j][i].set_title(str(j))
num_of_samples.append(len(x_selected))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment