From 7aff96cb8e2ccdcf5fe9f6eeb08f28b374eeb9f9 Mon Sep 17 00:00:00 2001 From: frasertajima <69366820+frasertajima@users.noreply.github.com> Date: Wed, 31 May 2023 16:16:51 -0700 Subject: [PATCH] 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 --- beginner_source/nn_tutorial.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/beginner_source/nn_tutorial.py b/beginner_source/nn_tutorial.py index bc32131b93..7ee7df3b43 100644 --- a/beginner_source/nn_tutorial.py +++ b/beginner_source/nn_tutorial.py @@ -75,6 +75,11 @@ import numpy as np pyplot.imshow(x_train[0].reshape((28, 28)), cmap="gray") +# ``pyplot.show()`` only if not on Colab +try: + import google.colab +except ImportError: + pyplot.show() print(x_train.shape) ###############################################################################