Skip to content

Commit 7aff96c

Browse files
frasertajimaSvetlana Karslioglu
and
Svetlana Karslioglu
authored
Update nn_tutorial.py (#2368)
* Update nn_tutorial.py Fix to #1303 "add pyplot.show() in beginner tutorial." Comments to issue suggested manually commenting out pyplot.show for users not using colab. --------- Co-authored-by: Svetlana Karslioglu <svekars@fb.com>
1 parent d55a262 commit 7aff96c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

beginner_source/nn_tutorial.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@
7575
import numpy as np
7676

7777
pyplot.imshow(x_train[0].reshape((28, 28)), cmap="gray")
78+
# ``pyplot.show()`` only if not on Colab
79+
try:
80+
import google.colab
81+
except ImportError:
82+
pyplot.show()
7883
print(x_train.shape)
7984

8085
###############################################################################

0 commit comments

Comments
 (0)