From f0756ceafd9f869ff3e76822f290ca5ef856d412 Mon Sep 17 00:00:00 2001 From: frasertajima <69366820+frasertajima@users.noreply.github.com> Date: Wed, 31 May 2023 12:13:14 -0700 Subject: [PATCH 1/3] 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. Instead, suggest change that imports colab and does nothing if user is running notebook on colab, otherwise it runs pyplot.show() (such as when running on a local machine). This way, manual editing of notebook is not required, colab users are undisturbed and local users get pyplot.show. --- beginner_source/nn_tutorial.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/beginner_source/nn_tutorial.py b/beginner_source/nn_tutorial.py index bc32131b93a..261c1b4a1bc 100644 --- a/beginner_source/nn_tutorial.py +++ b/beginner_source/nn_tutorial.py @@ -75,6 +75,12 @@ 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() + pass print(x_train.shape) ############################################################################### From 7c2f43e6fc08cf259c21d65808c99e28c5a79cdc Mon Sep 17 00:00:00 2001 From: frasertajima <69366820+frasertajima@users.noreply.github.com> Date: Wed, 31 May 2023 12:53:00 -0700 Subject: [PATCH 2/3] Update nn_tutorial.py removed unnecessary "pass" (because pyplot.show() is present). --- beginner_source/nn_tutorial.py | 1 - 1 file changed, 1 deletion(-) diff --git a/beginner_source/nn_tutorial.py b/beginner_source/nn_tutorial.py index 261c1b4a1bc..074fad7f857 100644 --- a/beginner_source/nn_tutorial.py +++ b/beginner_source/nn_tutorial.py @@ -80,7 +80,6 @@ import google.colab except ImportError: pyplot.show() - pass print(x_train.shape) ############################################################################### From ee73af64650e37935eb4354ce0f68ae27e794407 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Wed, 31 May 2023 15:43:15 -0700 Subject: [PATCH 3/3] Update beginner_source/nn_tutorial.py Fix for spellcheck --- beginner_source/nn_tutorial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beginner_source/nn_tutorial.py b/beginner_source/nn_tutorial.py index 074fad7f857..7ee7df3b435 100644 --- a/beginner_source/nn_tutorial.py +++ b/beginner_source/nn_tutorial.py @@ -75,7 +75,7 @@ import numpy as np pyplot.imshow(x_train[0].reshape((28, 28)), cmap="gray") -# pyplot.show() only if not on colab +# ``pyplot.show()`` only if not on Colab try: import google.colab except ImportError: