<reponame>lolimay/digit-recognition
"""
Visualize the MNIST dataset
"""

import os, sys
import matplotlib.pyplot as plt
sys.path.insert(0, os.path.abspath('..'))
from utils.load_mnist import load_mnist

images, labels = load_mnist('../dataset/MNIST/raw/')

fig, ax = plt.subplots(
    nrows=2,
    ncols=5,
    sharex=True,
    sharey=True, )

ax = ax.flatten()
for i in range(10):
    img = images[labels == i][0].reshape(28, 28)
    ax[i].imshow(img, cmap='Greys', interpolation='nearest')

ax[0].set_xticks([])
ax[0].set_yticks([])
plt.tight_layout()
plt.show()
"""
Visualize the MNIST dataset
"""

import os, sys
import matplotlib.pyplot as plt
sys.path.insert(0, os.path.abspath('..'))
from utils.load_mnist import load_mnist

images, labels = load_mnist('../dataset/MNIST/raw/')

fig, ax = plt.subplots(
    nrows=2,
    ncols=5,
    sharex=True,
    sharey=True, )

ax = ax.flatten()
for i in range(10):
    img = images[labels == i][0].reshape(28, 28)
    ax[i].imshow(img, cmap='Greys', interpolation='nearest')

ax[0].set_xticks([])
ax[0].set_yticks([])
plt.tight_layout()
plt.show()
Visualize the MNIST dataset