21
21
22
22
def main ():
23
23
training_set , validation_set , test_set = load_data ()
24
- images = get_images (training_set )
25
- plot_mnist_digit (images [ 0 ] )
24
+ images = get_images (training_set )[: 100 ]
25
+ plot_10_by_10_images (images )
26
26
27
27
#### Plotting
28
28
def plot_images_together (images ):
@@ -38,6 +38,21 @@ def plot_images_together(images):
38
38
plt .yticks (np .array ([]))
39
39
plt .show ()
40
40
41
+ def plot_10_by_10_images (images ):
42
+ """ Plot 100 MNIST images in a 10 by 10 table. Note that we crop
43
+ the images so that they appear reasonably close together. The
44
+ image is post-processed to give the appearance of being continued."""
45
+ fig = plt .figure ()
46
+ images = [image [3 :25 , 3 :25 ] for image in images ]
47
+ #image = np.concatenate(images, axis=1)
48
+ for x in range (10 ):
49
+ for y in range (10 ):
50
+ ax = fig .add_subplot (10 , 10 , 10 * y + x )
51
+ ax .matshow (images [10 * y + x ], cmap = matplotlib .cm .binary )
52
+ plt .xticks (np .array ([]))
53
+ plt .yticks (np .array ([]))
54
+ plt .show ()
55
+
41
56
def plot_images_separately (images ):
42
57
"Plot the six MNIST images separately."
43
58
fig = plt .figure ()
@@ -115,9 +130,9 @@ def load_data():
115
130
return (training_set , validation_set , test_set )
116
131
117
132
def get_images (training_set ):
118
- """ Return a list containing the first six images from the MNIST
133
+ """ Return a list containing the first 100 images from the MNIST
119
134
data set. Each image is represented as a 2-d numpy array."""
120
- flattened_images = training_set [0 ][:6 ]
135
+ flattened_images = training_set [0 ][:100 ]
121
136
return [np .reshape (f , (- 1 , 28 )) for f in flattened_images ]
122
137
123
138
#### Main
0 commit comments