diff --git a/datasets/cifar-10/cifar10.py b/datasets/cifar-10/cifar10_keras.py similarity index 90% rename from datasets/cifar-10/cifar10.py rename to datasets/cifar-10/cifar10_keras.py index c950f7e..b432083 100644 --- a/datasets/cifar-10/cifar10.py +++ b/datasets/cifar-10/cifar10_keras.py @@ -13,6 +13,11 @@ # limitations under the License. """CIFAR-10 dataset provider.""" +# From Python 3.9 and onward, `tuple`, `list` and other collection classes can +# also function as generic class types (see PEP 585). +# +# Once we no longer need to support Python 3.7 or 3.8, we can remove this syntax +# (added in PEP 563) for Python 3.7 and higher. from __future__ import annotations import numpy as np diff --git a/datasets/mnist/MNIST_-_Exploratory_Data_Analysis.ipynb b/datasets/mnist/MNIST_-_Exploratory_Data_Analysis.ipynb index 4ea5e29..025bff7 100644 --- a/datasets/mnist/MNIST_-_Exploratory_Data_Analysis.ipynb +++ b/datasets/mnist/MNIST_-_Exploratory_Data_Analysis.ipynb @@ -356,14 +356,14 @@ "source": [ "## Using the library to simplify input and label transformations\n", "\n", - "This directory provides [`mnist.py`][mnist-github] library which includes the\n", + "This directory provides [`mnist_keras.py`][mnist-github] library which includes the\n", "above transformations for scaling the input and converting the labels to a\n", "categorical (one-hot) representation from the default numeric values, so you\n", "can use it to simplify the data setup for training and testing MNIST models.\n", "\n", "You can see examples of how the library can be used in the [LeNet notebooks][lenet].\n", "\n", - "[mnist-github]: https://raw.githubusercontent.com/mbrukman/reimplementing-ml-papers/main/datasets/mnist/mnist.py\n", + "[mnist-github]: https://raw.githubusercontent.com/mbrukman/reimplementing-ml-papers/main/datasets/mnist/mnist_keras.py\n", "[lenet]: https://github.com/mbrukman/reimplementing-ml-papers/tree/main/lenet" ] } diff --git a/datasets/mnist/mnist.py b/datasets/mnist/mnist_keras.py similarity index 90% rename from datasets/mnist/mnist.py rename to datasets/mnist/mnist_keras.py index ba093aa..d8c9a42 100644 --- a/datasets/mnist/mnist.py +++ b/datasets/mnist/mnist_keras.py @@ -13,6 +13,11 @@ # limitations under the License. """MNIST dataset provider.""" +# From Python 3.9 and onward, `tuple`, `list` and other collection classes can +# also function as generic class types (see PEP 585). +# +# Once we no longer need to support Python 3.7 or 3.8, we can remove this syntax +# (added in PEP 563) for Python 3.7 and higher. from __future__ import annotations import numpy as np diff --git a/lenet/LeNet_Keras_v1_basic_implementation.ipynb b/lenet/LeNet_Keras_v1_basic_implementation.ipynb index b60da3b..ed149fe 100644 --- a/lenet/LeNet_Keras_v1_basic_implementation.ipynb +++ b/lenet/LeNet_Keras_v1_basic_implementation.ipynb @@ -73,7 +73,7 @@ "done\n", "\n", "# Download our library for processing MNIST dataset.\n", - "for module in mnist ; do\n", + "for module in mnist_keras ; do\n", " if ! [ -f \"${module}.py\" ]; then\n", " curl -sO \"https://raw.githubusercontent.com/${GH_USER}/${GH_REPO}/${GH_BRANCH}/datasets/mnist/${module}.py\"\n", " fi\n", @@ -185,7 +185,7 @@ "source": [ "%%capture --no-stderr\n", "\n", - "from mnist import MNIST\n", + "from mnist_keras import MNIST\n", "\n", "# This will download the MNIST dataset via the Keras library which outputs data\n", "# to stdout, so we silence it above to avoid extraneous output.\n", diff --git a/lenet/LeNet_Keras_v2_custom_Subsampling_layer_and_activation.ipynb b/lenet/LeNet_Keras_v2_custom_Subsampling_layer_and_activation.ipynb index 4b5e432..c9bc3e2 100644 --- a/lenet/LeNet_Keras_v2_custom_Subsampling_layer_and_activation.ipynb +++ b/lenet/LeNet_Keras_v2_custom_Subsampling_layer_and_activation.ipynb @@ -73,7 +73,7 @@ "done\n", "\n", "# Download our library for processing MNIST dataset.\n", - "for module in mnist ; do\n", + "for module in mnist_keras ; do\n", " if ! [ -f \"${module}.py\" ]; then\n", " curl -sO \"https://raw.githubusercontent.com/${GH_USER}/${GH_REPO}/${GH_BRANCH}/datasets/mnist/${module}.py\"\n", " fi\n", @@ -173,7 +173,7 @@ "source": [ "%%capture --no-stderr\n", "\n", - "from mnist import MNIST\n", + "from mnist_keras import MNIST\n", "\n", "# This will download the MNIST dataset via the Keras library which outputs data\n", "# to stdout, so we silence it above to avoid extraneous output.\n", diff --git a/lenet/LeNet_Keras_v3_Subsamping_fixed_scaling_and_learning_rate_decay.ipynb b/lenet/LeNet_Keras_v3_Subsamping_fixed_scaling_and_learning_rate_decay.ipynb index 75728a3..0dc3a69 100644 --- a/lenet/LeNet_Keras_v3_Subsamping_fixed_scaling_and_learning_rate_decay.ipynb +++ b/lenet/LeNet_Keras_v3_Subsamping_fixed_scaling_and_learning_rate_decay.ipynb @@ -73,7 +73,7 @@ "done\n", "\n", "# Download our library for processing MNIST dataset.\n", - "for module in mnist ; do\n", + "for module in mnist_keras ; do\n", " if ! [ -f \"${module}.py\" ]; then\n", " curl -sO \"https://raw.githubusercontent.com/${GH_USER}/${GH_REPO}/${GH_BRANCH}/datasets/mnist/${module}.py\"\n", " fi\n", @@ -200,11 +200,11 @@ "source": [ "%%capture --no-stderr\n", "\n", - "import mnist\n", + "from mnist_keras import MNIST\n", "\n", "# This will download the MNIST dataset via the Keras library which outputs data\n", "# to stdout, so we silence it above to avoid extraneous output.\n", - "mnist_data = mnist.MNIST()\n", + "mnist_data = MNIST()\n", "mnist_input_range = (-0.1, 1.175)" ] },