Skip to content

Instantly share code, notes, and snippets.

@vrjkmr
Created September 4, 2017 03:01
Show Gist options
  • Save vrjkmr/28e52d395b3229c50d48825356283b66 to your computer and use it in GitHub Desktop.
Save vrjkmr/28e52d395b3229c50d48825356283b66 to your computer and use it in GitHub Desktop.
# Sample 1
# Get 28x28 image
sample_1 = fashion_mnist.train.images[47].reshape(28,28)
# Get corresponding integer label from one-hot encoded data
sample_label_1 = np.where(fashion_mnist.train.labels[47] == 1)[0][0]
# Plot sample
print("y = {label_index} ({label})".format(label_index=sample_label_1, label=label_dict[sample_label_1]))
plt.imshow(sample_1, cmap='Greys')
# Sample 2
# Get 28x28 image
sample_2 = fashion_mnist.train.images[23].reshape(28,28)
# Get corresponding integer label from one-hot encoded data
sample_label_2 = np.where(fashion_mnist.train.labels[23] == 1)[0][0]
# Plot sample
print("y = {label_index} ({label})".format(label_index=sample_label_2, label=label_dict[sample_label_2]))
plt.imshow(sample_2, cmap='Greys')
@sewonkimm
Copy link


KeyError Traceback (most recent call last)
in ()
8
9 # Plot sample
---> 10 print("y = {label_index} ({label})".format(label_index=sample_label_1, label=label_dict[sample_label_1]))
11 plt.imshow(sample_1, cmap='Greys')
12

KeyError: 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment