Hey hey,
I am playing around with the code to build a softmax neural network to recognise handwritten digits (as in the Assignment from week 2).
This is the code to visualize 64 random handwritten digits from the training dataset.
m,n = X.shape
fig, ax = plt.subplots(8,8, figsize = (5,5))
fig.tight_layout(pad=0.15,rect=[0,.03, 1, 0.91])
for i, axes in enumerate(ax.flat):
random = np.random.randint(m)
X_random_reshaped = X[random].reshape((20,20)).T
axes.imshow(X_random_reshaped, cmap = “gray”)
axes.set_title(Y[random,0])
axes.set_axis_off()
fig.suptitle(“Label, image”, fontsize = 14)
I don’t understand what enumerate(ax.flat) is? What exactly are the variables i and axes getting iterated by?
Thanks!
Cheers
Nadi