Skip to content

Commit 6d0086e

Browse files
committed
mnist plottting
1 parent f25a6ee commit 6d0086e

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

mitdeeplearning/lab2.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,37 @@
99

1010
IM_SHAPE = (64, 64, 3)
1111

12+
def plot_image_prediction(i, predictions_array, true_label, img):
13+
predictions_array, true_label, img = predictions_array[i], true_label[i], img[i]
14+
plt.grid(False)
15+
plt.xticks([])
16+
plt.yticks([])
17+
18+
plt.imshow(np.squeeze(img), cmap=plt.cm.binary)
19+
20+
predicted_label = np.argmax(predictions_array)
21+
if predicted_label == true_label:
22+
color = 'blue'
23+
else:
24+
color = 'red'
25+
26+
plt.xlabel("{} {:2.0f}% ({})".format(predicted_label,
27+
100*np.max(predictions_array),
28+
true_label),
29+
color=color)
30+
31+
def plot_value_prediction(i, predictions_array, true_label):
32+
predictions_array, true_label = predictions_array[i], true_label[i]
33+
plt.grid(False)
34+
plt.xticks([])
35+
plt.yticks([])
36+
thisplot = plt.bar(range(10), predictions_array, color="#777777")
37+
plt.ylim([0, 1])
38+
predicted_label = np.argmax(predictions_array)
39+
40+
thisplot[predicted_label].set_color('red')
41+
thisplot[true_label].set_color('blue')
42+
1243

1344
class TrainingDatasetLoader(object):
1445
def __init__(self, data_path):

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ def get_dist(pkgname):
2121
setup(
2222
name = 'mitdeeplearning', # How you named your package folder (MyLib)
2323
packages = ['mitdeeplearning'], # Chose the same as "name"
24-
version = '0.3.8', # Start with a small number and increase it with every change you make
24+
version = '0.3.9', # Start with a small number and increase it with every change you make
2525
license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository
2626
description = 'Official software labs for MIT Introduction to Deep Learning (http://introtodeeplearning.com)', # Give a short description about your library
2727
author = 'Alexander Amini', # Type in your name
2828
author_email = '[email protected]', # Type in your E-Mail
2929
url = 'http://introtodeeplearning.com', # Provide either the link to your github or to your website
30-
download_url = 'https://github.com/aamini/introtodeeplearning_labs/archive/v0.3.8.tar.gz', # I explain this later on
30+
download_url = 'https://github.com/aamini/introtodeeplearning_labs/archive/v0.3.9.tar.gz', # I explain this later on
3131
keywords = ['deep learning', 'neural networks', 'tensorflow', 'introduction'], # Keywords that define your package best
3232
install_requires=install_deps,
3333
classifiers=[

0 commit comments

Comments
 (0)