Problem 2
Let’s verify that the data still looks good. Displaying a sample of the labels and images from the ndarray. Hint: you can use matplotlib.pyplot.
import matplotlib as mpl
set_filename = train_folders[1] + '.pickle'
try:
with open(set_filename, 'rb') as f:
data = pickle.load(f)
except Exception as e:
print('Unable to read data from', set_filename, ':', e)
data_small = data[::500]
for x in data_small:
plt.imshow(x, cmap=mpl.cm.gray_r)
plt.show()
Problem 3
Another check: we expect the data to be balanced across classes. Verify that.
for num in range(10):
set_filename = train_folders[num] + '.pickle'
try:
with open(set_filename, 'rb') as f:
data = pickle.load(f)
except Exception as e:
print('Unable to read data from', set_filename, ':', e)
print(data.shape[0])