A Top Down Approach to Machine Learning: +Bonus Hands-On Tutorial by Marty Jacobs

A Top Down Approach to Machine Learning: +Bonus Hands-On Tutorial by Marty Jacobs

Author:Marty Jacobs [Jacobs, Marty]
Language: eng
Format: azw3
Published: 2017-10-25T04:00:00+00:00


def show_grid_3x3(images):

"""

Display a 3x3 grid of 9 randomly sampled numpy array images.

: images: A batch of image data. Numpy array with shape (batch_size, 28, 28, 1)

"""

plt.rcParams['figure.figsize'] = 6, 6

fig, axes = plt.subplots(nrows=3, ncols=3, sharex=True, sharey=True)

rand_idx = np.random.choice(images.shape[0], 9, replace=False) # get 5 random indices

images = images[rand_idx]

for i in range(3):

for j in range(3):

axes[i, j].imshow(images[i + 3*j].reshape((28, 28)), cmap='gray')

plt.tight_layout()



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.