Last active
October 19, 2017 10:10
-
-
Save udoprog/a37deae537270832c436d825f29aadd5 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
import matplotlib.pyplot as plt | |
import numpy as np | |
from sklearn.datasets import fetch_mldata | |
mnist = fetch_mldata("MNIST original") | |
def plot_images(datas, titles): | |
fig, axes = plt.subplots(4, int(len(datas) / 4)) | |
fig.set_size_inches((10, 10)) | |
for data, title, ax in zip(datas, titles, axes.ravel()): | |
img = np.reshape(data, [28, 28]) | |
ax.set_title(str(title)) | |
ax.imshow(img, cmap=plt.cm.gray) | |
ax.set_xticks(()) | |
ax.set_yticks(()) | |
fig.tight_layout() | |
plt.show() | |
indexes = np.random.choice(len(mnist.data), 4 * 4) | |
plot_images(mnist.data[indexes], mnist.target[indexes]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment