From a125cd7cc3d53f2b26706907f116c7e61ba3c7eb Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Sun, 3 Jan 2021 17:16:08 -0500 Subject: [PATCH 01/27] Add section in README on running code for Intro to Practical NN and DL class --- README.md | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/README.md b/README.md index aa618b0..0a425f0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,122 @@ +## Running IEEE Boston Section class demo code +Introduction to Practical Neural Networks and Deep Learning (Part 1) March 20, 2021 + +###### Why using docker container +In order to avoid needing to give out separate instructions on how to install Python and needed packages to run the book's code on different platforms/flavors (such as Mac, Windows, Linux), +it seemed easier to just give one set of instructions on how to create a docker container and how to run the demo code in it. +Hopefully, docker is sufficiently ubiquitous nowadays so that installing and running docker on different platforms should be well documented. + +#### How to: clone repo, run docker container, run demo +Clone repo locally at command line, `cd` into repo directory, `git checkout` branch that has desired setup of demo code you want to run. + +Acknowledgement: The repo is forked from _DeepLearningPython35_ repo of Michal Daniel Dobrzanski who ported the book's code from Python 2.7 to Python 3.5 and wrote the 'wrapper' test.py +``` +~ $ git clone https://github.com/clkim/DeepLearningPython35.git +~ $ cd DeepLearningPython35 +~/DeepLearningPython35 $ git checkout chap1_30-hidden-neurons-3.0-eta +``` +In order to run the desired setup of demo code, comment in/out or add/modify the code as appropriate in `test.py` in order to specify the neural network and deep learning configuration to run. + +To see an example of the (flexible but somewhat hackish and minimalist) changes I made in `test.py` in order to run the demo in the chap1 branch, +at command line run `git diff ea229ac 6ba2425` to see the small change committed in the branch. + + +Run _Docker Desktop_ app locally (currently 3.0.3 for Mac). + +At repo directory, start docker container _deeplearning_ (see below for how to create container). +In container shell `cd` into mounted repo directory (which should be already on desired git branch, e.g. chap1_30-hidden-neurons-3.0-eta). +``` +~/DeepLearningPython35 $ docker container ls --all +< Should see a table with column names CONTAINER ID ... NAMES, and a row with container named deeplearning > + +~/DeepLearningPython35 $ docker container start -ai deeplearning +(base) root@xxx:/# cd deeplearn/ +(base) root@xxx:/deeplearn# python --version +Python 3.8.5 +(base) root@xxx:/deeplearn# conda info --env +< Should see two environments: base and nndlbook > +(base) root@xxx:/deeplearn# conda activate nndlbook + +(nndlbook) root@xxx:/deeplearn# python3.8 test.py +Epoch 0 : 8943 / 10000 +Epoch 1 : 9166 / 10000 +Epoch 2 : 9267 / 10000 +Epoch 3 : 9340 / 10000 +Epoch 4 : 9337 / 10000 +Epoch 5 : 9374 / 10000 +Epoch 6 : 9386 / 10000 +< On my late 2013 MacBook Pro, it takes about a minute to finish Epoch 6; control-C to break > +(nndlbook) root@xxx:/deeplearn# exit +exit +~/DeepLearningPython35 $ +``` +#### How to create docker container +(We want to mount a directory so Python source code is accessible from inside container; and we want to install numpy package and theano package.) + +Run _Docker Desktop_ app locally (currently 3.0.3 for Mac). + +First run docker to download miniconda3 image. +Then run docker to create the container and install the packages. +``` +~ $ docker pull continuumio/miniconda3 +Using default tag: latest +... +docker.io/continuumio/miniconda3:latest + +~ $ docker images +< Should see a table with column names REPOSITORY ... SIZE, and a row with image repository/name continuumio/miniconda3 > + +< Now cd into the repo directory, after cloning repo from github as given above > +< Then run docker to create a new container layer over the downloaded image, and create a new conda environment where we install packages > +~ $ cd DeepLearningPython35 +~/DeepLearningPython35 $ docker run -it --name deeplearning --mount type=bind,source="$(pwd)",target=/deeplearn continuumio/miniconda3 + +(base) root@xxx:/# conda --version +conda 4.9.2 +(base) root@xxx:/# conda create --name nndlbook +Collecting package metadata (current_repodata.json): done +... +Proceed ([y]/n)? y +... +# To activate this environment, use +# +# $ conda activate nndlbook +... + +(base) root@xxx:/# conda activate nndlbook +(nndlbook) root@xxx:/# conda list +# packages in environment at /opt/conda/envs/nndlbook: +# +# Name Version Build Channel +(nndlbook) root@xxx:/# python --version +Python 3.8.5 + +(nndlbook) root@x:/# conda install numpy +Collecting package metadata (current_repodata.json): done +... +Proceed ([y]/n)? y +... +... +Executing transaction: done + +(nndlbook) root@xxx:/# conda install theano +Collecting package metadata (current_repodata.json): done +... +Proceed ([y]/n)? y +... +... +Executing transaction: done + +(nndlbook) root@xxx:/# conda list +< Should see list of packages including numpy and theano > + +(nndlbook) root@xxx:/# exit +exit +~/DeepLearningPython35 $ docker container ls --all +< Should see a table with column names CONTAINER ID ... NAMES, and a row with container named deeplearning > +``` +___ + ## Overview ### neuralnetworksanddeeplearning.com integrated scripts for Python 3.5.2 and Theano with CUDA support From 2e71dbd25f70b68090941c1c087ce027fae35360 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Thu, 11 Mar 2021 20:50:42 -0500 Subject: [PATCH 02/27] Update README on running demo code for NN and DL class --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0a425f0..3f70ff4 100644 --- a/README.md +++ b/README.md @@ -15,19 +15,19 @@ Acknowledgement: The repo is forked from _DeepLearningPython35_ repo of Michal D ~ $ cd DeepLearningPython35 ~/DeepLearningPython35 $ git checkout chap1_30-hidden-neurons-3.0-eta ``` -In order to run the desired setup of demo code, comment in/out or add/modify the code as appropriate in `test.py` in order to specify the neural network and deep learning configuration to run. +To run the desired setup of demo code, "comment in/out" as appropriate the code in `test.py` in order to specify the neural network and deep learning configuration to run. To see an example of the (flexible but somewhat hackish and minimalist) changes I made in `test.py` in order to run the demo in the chap1 branch, -at command line run `git diff ea229ac 6ba2425` to see the small change committed in the branch. +at command line run `git diff 11cd4c1 6ba2425` to see the small change committed in the branch. Run _Docker Desktop_ app locally (currently 3.0.3 for Mac). At repo directory, start docker container _deeplearning_ (see below for how to create container). -In container shell `cd` into mounted repo directory (which should be already on desired git branch, e.g. chap1_30-hidden-neurons-3.0-eta). +In container shell `cd` into the mounted directory (points to DeepLearningPython35, which should be already on the desired git branch, e.g. chap1_30-hidden-neurons-3.0-eta). ``` ~/DeepLearningPython35 $ docker container ls --all -< Should see a table with column names CONTAINER ID ... NAMES, and a row with container named deeplearning > +< Should see a table with column names CONTAINER ID ... NAMES, and container named deeplearning > ~/DeepLearningPython35 $ docker container start -ai deeplearning (base) root@xxx:/# cd deeplearn/ @@ -46,6 +46,8 @@ Epoch 4 : 9337 / 10000 Epoch 5 : 9374 / 10000 Epoch 6 : 9386 / 10000 < On my late 2013 MacBook Pro, it takes about a minute to finish Epoch 6; control-C to break > +< Each epoch run uses all training images, then evaluates the neural network with test images > + (nndlbook) root@xxx:/deeplearn# exit exit ~/DeepLearningPython35 $ From 977fae23eb7bd261b5c6b323634f5ddde9e54ed4 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Fri, 12 Mar 2021 01:22:56 -0500 Subject: [PATCH 03/27] More updating of README for the NN and DL class --- README.md | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 3f70ff4..6c2053d 100644 --- a/README.md +++ b/README.md @@ -3,28 +3,32 @@ Introduction to Practical Neural Networks and Deep Learning (Part 1) March 20, 2 ###### Why using docker container In order to avoid needing to give out separate instructions on how to install Python and needed packages to run the book's code on different platforms/flavors (such as Mac, Windows, Linux), -it seemed easier to just give one set of instructions on how to create a docker container and how to run the demo code in it. +it seemed easier to just give one set of instructions on how to create a _docker_ container and how to run the demo code in it. Hopefully, docker is sufficiently ubiquitous nowadays so that installing and running docker on different platforms should be well documented. -#### How to: clone repo, run docker container, run demo -Clone repo locally at command line, `cd` into repo directory, `git checkout` branch that has desired setup of demo code you want to run. +#### How to: clone github repository, run docker container, run demo +Clone _github_ repository locally at command line, then +`cd` into repo directory, then +`git checkout` branch that has desired setup of demo code you want to run. -Acknowledgement: The repo is forked from _DeepLearningPython35_ repo of Michal Daniel Dobrzanski who ported the book's code from Python 2.7 to Python 3.5 and wrote the 'wrapper' test.py + +Acknowledgement: The repository is forked from _DeepLearningPython35_ repository of _Michal Daniel Dobrzanski_ who ported the book's code from Python 2.7 to Python 3.5 and wrote the "orchestrator" testing file `test.py` ``` ~ $ git clone https://github.com/clkim/DeepLearningPython35.git ~ $ cd DeepLearningPython35 ~/DeepLearningPython35 $ git checkout chap1_30-hidden-neurons-3.0-eta ``` -To run the desired setup of demo code, "comment in/out" as appropriate the code in `test.py` in order to specify the neural network and deep learning configuration to run. +To run the desired setup of demo code, "uncomment in" or "comment out" as appropriate the code in `test.py` in order to specify the neural network and deep learning configuration to run. -To see an example of the (flexible but somewhat hackish and minimalist) changes I made in `test.py` in order to run the demo in the chap1 branch, -at command line run `git diff 11cd4c1 6ba2425` to see the small change committed in the branch. +To see an example of the (flexible but somewhat hackish and minimalist) changes I made in `test.py` in order to run the demo in the chap1 branch, at command line run +`git diff ea229ac 6ba2425` +to see the small changes committed in the branch. Run _Docker Desktop_ app locally (currently 3.0.3 for Mac). -At repo directory, start docker container _deeplearning_ (see below for how to create container). -In container shell `cd` into the mounted directory (points to DeepLearningPython35, which should be already on the desired git branch, e.g. chap1_30-hidden-neurons-3.0-eta). +At repo directory, start `docker` container _deeplearning_ (see below for how to create container). +In container shell `cd` into the mounted directory (points to local _DeepLearningPython35_ directory, which should be already on the desired git branch, e.g. chap1_30-hidden-neurons-3.0-eta). ``` ~/DeepLearningPython35 $ docker container ls --all < Should see a table with column names CONTAINER ID ... NAMES, and container named deeplearning > @@ -45,20 +49,20 @@ Epoch 3 : 9340 / 10000 Epoch 4 : 9337 / 10000 Epoch 5 : 9374 / 10000 Epoch 6 : 9386 / 10000 -< On my late 2013 MacBook Pro, it takes about a minute to finish Epoch 6; control-C to break > -< Each epoch run uses all training images, then evaluates the neural network with test images > +< On my late-2013 MacBook Pro, it takes about a minute to finish Epoch 6; control-C to break > +< Each epoch run uses all training images; then neural network is evaluated on test images > (nndlbook) root@xxx:/deeplearn# exit exit ~/DeepLearningPython35 $ ``` #### How to create docker container -(We want to mount a directory so Python source code is accessible from inside container; and we want to install numpy package and theano package.) +(We want to mount a directory so that the demo Python code on our computer is accessible from inside the container; and we want to install _Numpy_ package and _Theano_ package.) Run _Docker Desktop_ app locally (currently 3.0.3 for Mac). -First run docker to download miniconda3 image. -Then run docker to create the container and install the packages. +First run `docker` to download _miniconda3_ image. +Then run `docker` to create the container and install the packages. ``` ~ $ docker pull continuumio/miniconda3 Using default tag: latest @@ -69,7 +73,7 @@ docker.io/continuumio/miniconda3:latest < Should see a table with column names REPOSITORY ... SIZE, and a row with image repository/name continuumio/miniconda3 > < Now cd into the repo directory, after cloning repo from github as given above > -< Then run docker to create a new container layer over the downloaded image, and create a new conda environment where we install packages > +< Then run docker to create a new container layer over the downloaded image, then create a new conda environment in which we install needed packages > ~ $ cd DeepLearningPython35 ~/DeepLearningPython35 $ docker run -it --name deeplearning --mount type=bind,source="$(pwd)",target=/deeplearn continuumio/miniconda3 @@ -115,7 +119,7 @@ Executing transaction: done (nndlbook) root@xxx:/# exit exit ~/DeepLearningPython35 $ docker container ls --all -< Should see a table with column names CONTAINER ID ... NAMES, and a row with container named deeplearning > +< Should see a table with column names CONTAINER ID ... NAMES, and container named deeplearning > ``` ___ From 1a52c9626b54938f7629029bb82814d492662745 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Fri, 12 Mar 2021 01:45:19 -0500 Subject: [PATCH 04/27] Yet more updating of README for the NN and DL class --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 6c2053d..c94d409 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ In container shell `cd` into the mounted directory (points to local _DeepLearnin Python 3.8.5 (base) root@xxx:/deeplearn# conda info --env < Should see two environments: base and nndlbook > + (base) root@xxx:/deeplearn# conda activate nndlbook (nndlbook) root@xxx:/deeplearn# python3.8 test.py @@ -90,10 +91,12 @@ Proceed ([y]/n)? y ... (base) root@xxx:/# conda activate nndlbook + (nndlbook) root@xxx:/# conda list # packages in environment at /opt/conda/envs/nndlbook: # # Name Version Build Channel + (nndlbook) root@xxx:/# python --version Python 3.8.5 From 98f859ee508ea08b3cf148882008d348c2dc8775 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Sun, 18 Apr 2021 00:22:13 -0400 Subject: [PATCH 05/27] Update README to be pre-class installation instructions, for June 19 NNDL class --- README.md | 224 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 159 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index c94d409..1cdff99 100644 --- a/README.md +++ b/README.md @@ -1,85 +1,117 @@ ## Running IEEE Boston Section class demo code -Introduction to Practical Neural Networks and Deep Learning (Part 1) March 20, 2021 - -###### Why using docker container -In order to avoid needing to give out separate instructions on how to install Python and needed packages to run the book's code on different platforms/flavors (such as Mac, Windows, Linux), -it seemed easier to just give one set of instructions on how to create a _docker_ container and how to run the demo code in it. -Hopefully, docker is sufficiently ubiquitous nowadays so that installing and running docker on different platforms should be well documented. - -#### How to: clone github repository, run docker container, run demo -Clone _github_ repository locally at command line, then -`cd` into repo directory, then -`git checkout` branch that has desired setup of demo code you want to run. - - -Acknowledgement: The repository is forked from _DeepLearningPython35_ repository of _Michal Daniel Dobrzanski_ who ported the book's code from Python 2.7 to Python 3.5 and wrote the "orchestrator" testing file `test.py` +## Introduction to Practical Neural Networks and Deep Learning (Part 1)
June 19, 2021 + + +##### Why use Docker container +In order to avoid potential problems with installing Python and the needed packages to run the book's demo code on different platforms such as Mac, Windows, or Linux, +we decided to create a _Docker_ container and to run the demo code in it. +Docker is sufficiently popular nowadays so that installing as well as running Docker on different platforms should be well supported and documented. + +### How to download Git software +Git is a very popular source code management tool for version control, widely used among software professionals. + +Estimate time: 15 mins. +Go to [Install Git](https://www.atlassian.com/git/tutorials/install-git), and scroll to Install Git on \[Mac OS X | Windows | Linux\] section as appropriate. +Unless you have a preference, probably just pick the first method for your platform. + +(For Mac: +Just install Git; you should not need to install git-credential-osxkeychain helper. +If you're installing from a downloaded .dmg file, you may be blocked from opening the installation package; if you see "macOS cannot verify that this app is free from malware", +go to _System Preferences_ > _Security & Privacy_ > click `Open Anyway` for that downloaded git-xxx.pkg file.) + +### How to download Docker software +A _container_, in software engineering parlance, packages up code and all its dependencies into a standard unit of software so that the application can run +quickly and reliably from one computing environment to another. +Docker is a very popular container technology. The containers run on _Docker Engine_. + +Estimate time: 15 mins. +Go to [Get Docker](https://docs.docker.com/get-docker/), and pick Docker \[Desktop for Mac | Desktop for Windows | for Linux\] to do the appropriate install. +For Mac and Windows, after doing _Install Docker Desktop_, also run _Docker Desktop_, so as to start _Docker Engine_. For Linux, install _Docker Engine_ then start _Docker_. + +### How to clone GitHub repository into local directory +Estimate time: 10 mins. +The commands shown in the text area below do the following; the text area also shows the _Terminal_ console response to the commands: +- Clone with `git clone https://github.com/...` the specified _GitHub_ repository at a Terminal command line; this downloads the demo source code from that specified repository into your local computer +- `cd DeepLearningPython35` into the repository directory; this changes your directory to the directory of the downloaded demo Python source code +- Verify with `git branch` that you are on the _master_ branch of the repository; the branch you are on is marked with an asterisk (*); +a repository can have many versions of the source code, each stored in its own branch +- Checkout the desired branch instead of master branch, with `git checkout chap1_30-hidden-neurons-3.0-eta`; that specified branch has the desired setup of demo code you want to run +- Verify with `git branch` again that you are on the desired branch _chap1_30-hidden-neurons-3.0-eta_ which is now marked with an asterisk (*) ``` +~ $ _ ~ $ git clone https://github.com/clkim/DeepLearningPython35.git -~ $ cd DeepLearningPython35 -~/DeepLearningPython35 $ git checkout chap1_30-hidden-neurons-3.0-eta -``` -To run the desired setup of demo code, "uncomment in" or "comment out" as appropriate the code in `test.py` in order to specify the neural network and deep learning configuration to run. - -To see an example of the (flexible but somewhat hackish and minimalist) changes I made in `test.py` in order to run the demo in the chap1 branch, at command line run -`git diff ea229ac 6ba2425` -to see the small changes committed in the branch. +~ $ cd DeepLearningPython35 -Run _Docker Desktop_ app locally (currently 3.0.3 for Mac). - -At repo directory, start `docker` container _deeplearning_ (see below for how to create container). -In container shell `cd` into the mounted directory (points to local _DeepLearningPython35_ directory, which should be already on the desired git branch, e.g. chap1_30-hidden-neurons-3.0-eta). -``` -~/DeepLearningPython35 $ docker container ls --all -< Should see a table with column names CONTAINER ID ... NAMES, and container named deeplearning > - -~/DeepLearningPython35 $ docker container start -ai deeplearning -(base) root@xxx:/# cd deeplearn/ -(base) root@xxx:/deeplearn# python --version -Python 3.8.5 -(base) root@xxx:/deeplearn# conda info --env -< Should see two environments: base and nndlbook > - -(base) root@xxx:/deeplearn# conda activate nndlbook +~/DeepLearningPython35 $ git branch + chap1_30-hidden-neurons-3.0-eta + chap2_fully-matrix-based-backpropagation-mini-batch + chap6 +* master -(nndlbook) root@xxx:/deeplearn# python3.8 test.py -Epoch 0 : 8943 / 10000 -Epoch 1 : 9166 / 10000 -Epoch 2 : 9267 / 10000 -Epoch 3 : 9340 / 10000 -Epoch 4 : 9337 / 10000 -Epoch 5 : 9374 / 10000 -Epoch 6 : 9386 / 10000 -< On my late-2013 MacBook Pro, it takes about a minute to finish Epoch 6; control-C to break > -< Each epoch run uses all training images; then neural network is evaluated on test images > +~/DeepLearningPython35 $ git checkout chap1_30-hidden-neurons-3.0-eta -(nndlbook) root@xxx:/deeplearn# exit -exit -~/DeepLearningPython35 $ +~/DeepLearningPython35 $ git branch +* chap1_30-hidden-neurons-3.0-eta + chap2_fully-matrix-based-backpropagation-mini-batch + chap6 + master +~/DeepLearningPython35 $ _ ``` -#### How to create docker container -(We want to mount a directory so that the demo Python code on our computer is accessible from inside the container; and we want to install _Numpy_ package and _Theano_ package.) +(Skip until class) To run the desired setup of demo code, "uncomment in" or "comment out" as appropriate the code in _test.py_ in order to specify +the neural network and deep learning configuration to run. -Run _Docker Desktop_ app locally (currently 3.0.3 for Mac). - -First run `docker` to download _miniconda3_ image. -Then run `docker` to create the container and install the packages. +(Skip until class) To see an example of the (flexible but somewhat hackish and minimalist) changes I made in _test.py_ in order to run the demo +in the chap1 branch, at command line run +`git diff ea229ac 6ba2425` +to see the small changes committed in the branch (red text is deleted, green text is added; hit space bar once to scroll down one page; +when we see the (END) of document, enter q to quit and get back to the command line). + +Acknowledgement: The repository is forked from the _DeepLearningPython35_ repository of _Michal Daniel Dobrzanski_ who ported the book's code from +Python 2.7 to Python 3.5 and wrote the "orchestrator" testing file _test.py_. + +### How to create a Docker container locally to run the demo Python code +Background: We want to set up a "bind" type of mount in the container whose source is the directory in our local computer where the demo Python source code +has been cloned from GitHub, so that the source code on our local computer would be accessible from inside the container. +We also want to install two Python packages, _Numpy_ package and _Theano_ package, in the container we want to create. + +Ensure that you have already started Docker Engine, e.g. by running _Docker Desktop_ app locally; +and that you have already cloned the demo Python source code from GitHub, into the _DeepLearningPython35_ directory, +as described above in "How to clone GitHub repository into local directory". + +`cd` into the directory _DeepLearningPython35_ if not already there. + +Estimate time: 15 - 30 mins. +The commands shown in the text area below do the following; the text area also shows the _Terminal_ console response to the commands: +- First run `docker pull continuumio/miniconda3` to download the _miniconda3_ image, which contains _conda_, a small version of Anaconda +which is a very popular data science platform +- Then run `docker images` to verify the image _continuumio/miniconda3_ is downloaded +- Then run the given `docker` command to create a new container layer over the downloaded image + - At the interactive shell command line inside the container, we check the conda version, with `conda --version` + - Then create our own environment, named _nndlbook_ for our own use, with `conda create --nndlbook` + - Then we active this new _nndlbook_ conda environment, with `conda activate nndlbook` + - Next, do a perfunctory check that no additional packages are installed yet, with `conda list` + - Do a check that we do have python installed already, with `python --version` + - Now, we are ready to install our packages, with `conda install numpy` and then `conda install theano` + - Finally, we do a check that we see those two package names, among others, with `conda list` + - Then we exit our newly created local container, with `exit` +- Back at the Terminal command line, verify that we have created a local container named _deeplearning_, with `docker container ls --all` ``` -~ $ docker pull continuumio/miniconda3 +~/DeepLearningPython35 $ _ +~/DeepLearningPython35 $ docker pull continuumio/miniconda3 Using default tag: latest ... docker.io/continuumio/miniconda3:latest -~ $ docker images -< Should see a table with column names REPOSITORY ... SIZE, and a row with image repository/name continuumio/miniconda3 > +~/DeepLearningPython35 $ docker images +REPOSITORY TAG IMAGE ID CREATED SIZE +continuumio/miniconda3 latest xxxxxxxxxxxx n months ago nnnMB -< Now cd into the repo directory, after cloning repo from github as given above > -< Then run docker to create a new container layer over the downloaded image, then create a new conda environment in which we install needed packages > -~ $ cd DeepLearningPython35 ~/DeepLearningPython35 $ docker run -it --name deeplearning --mount type=bind,source="$(pwd)",target=/deeplearn continuumio/miniconda3 (base) root@xxx:/# conda --version conda 4.9.2 + (base) root@xxx:/# conda create --name nndlbook Collecting package metadata (current_repodata.json): done ... @@ -87,7 +119,6 @@ Proceed ([y]/n)? y ... # To activate this environment, use # -# $ conda activate nndlbook ... (base) root@xxx:/# conda activate nndlbook @@ -121,9 +152,72 @@ Executing transaction: done (nndlbook) root@xxx:/# exit exit + +~/DeepLearningPython35 $ docker container ls --all +< Should see a container named "deeplearning" > +CONTAINER ID IMAGE COMMAND CREATED ... NAMES +xxxxxxxxxxxx continuumio/miniconda3 "/bin/bash" xxx deeplearning +``` + +### How to run the demo Python code in the created Docker container +Estimate time: 10 mins. +Ensure that you have already started Docker Engine, e.g. by running _Docker Desktop_ app locally; +and that you have already cloned the demo Python source code from GitHub, into the _DeepLearningPython35_ directory, as described above +in "How to clone GitHub repository into local directory". + +`cd` into the directory _DeepLearningPython35_ if not already there. + +You must be on the branch _chap1_30-hidden-neurons-3.0-eta_. +Verify with `git branch` (see section on "How to clone GitHub repository into local directory"). +If not, do `git checkout chap1_30-hidden-neurons-3.0-eta` to switch to that branch, then verify with `git branch`. + +The commands shown in the text area below do the following; the text area also shows the _Terminal_ console response to the commands: +- First, just verify we see the newly created container named _deeplearning_ +- At _DeepLearningPython35_ directory, start `docker` container _deeplearning_ and specifying option to attach an interactive shell, + with `docker container start -ai deeplearning` + - At the interactive shell command line inside the container, we `cd` into the _deeplearn_ directory mounted into the container; + we had bind the mount to the local _DeepLearningPython35_ directory, which must be already on the git branch _chap1_30-hidden-neurons-3.0-eta_ + - We check the python version, with `python --version` + - And verify what conda environments we have, with `conda info --env` + - Then we activate our own conda environment _nndlbook_, with `conda activate nndlbook` + - Finally, we now run the demo code in _test.py_, with `python3.8 test.py` + - After the run, we exit the container, with `exit` +- Now we should be back at the Terminal command line, in the _DeepLearningPython35_ directory +``` +~/DeepLearningPython35 $ _ ~/DeepLearningPython35 $ docker container ls --all -< Should see a table with column names CONTAINER ID ... NAMES, and container named deeplearning > +< Should see a container named "deeplearning" > +CONTAINER ID IMAGE COMMAND CREATED ... NAMES +xxxxxxxxxxxx continuumio/miniconda3 "/bin/bash" xxx deeplearning + +~/DeepLearningPython35 $ docker container start -ai deeplearning + +(base) root@xxx:/# cd deeplearn/ + +(base) root@xxx:/deeplearn# python --version +Python 3.8.5 + +(base) root@xxx:/deeplearn# conda info --env +< Should see two environments: base and nndlbook > + +(base) root@xxx:/deeplearn# conda activate nndlbook + +(nndlbook) root@xxx:/deeplearn# python3.8 test.py +Epoch 0 : 8943 / 10000 +Epoch 1 : 9166 / 10000 +Epoch 2 : 9267 / 10000 +Epoch 3 : 9340 / 10000 +Epoch 4 : 9337 / 10000 +Epoch 5 : 9374 / 10000 +Epoch 6 : 9386 / 10000 +< On my late-2013 MacBook Pro, it takes about a minute to finish Epoch 6; control-C to break > +< Each epoch run uses the training images; then neural network is evaluated on test images > + +(nndlbook) root@xxx:/deeplearn# exit +exit +~/DeepLearningPython35 $ _ ``` +### End of README for IEEE Boston: Introduction to Practical Neural Networks and Deep Learning (Part 1) ___ ## Overview From 128bd785d2883891e75f8fe7a02bc9c5a8707b17 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Sat, 12 Jun 2021 02:16:48 -0400 Subject: [PATCH 06/27] Improve README --- README.md | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 1cdff99..585ba9e 100644 --- a/README.md +++ b/README.md @@ -15,30 +15,35 @@ Go to [Install Git](https://www.atlassian.com/git/tutorials/install-git), and sc Unless you have a preference, probably just pick the first method for your platform. (For Mac: -Just install Git; you should not need to install git-credential-osxkeychain helper. -If you're installing from a downloaded .dmg file, you may be blocked from opening the installation package; if you see "macOS cannot verify that this app is free from malware", -go to _System Preferences_ > _Security & Privacy_ > click `Open Anyway` for that downloaded git-xxx.pkg file.) +Git for Mac Installer > pick latest link (currently `git-2.31.0-intel-universal-mavericks.dmg`); +if you're installing from a downloaded .dmg file, you may be blocked from opening the installation package; if you see +"macOS cannot verify that this app is free from malware", go to _System Preferences_ > _Security & Privacy_ > click `Open Anyway` for that downloaded git-xxx.pkg file. +Install just Git; you should not need to install git-credential-osxkeychain helper. ### How to download Docker software -A _container_, in software engineering parlance, packages up code and all its dependencies into a standard unit of software so that the application can run +In software engineering parlance, a _container_ packages up code and all its dependencies into a standard unit of software so that the application can run quickly and reliably from one computing environment to another. Docker is a very popular container technology. The containers run on _Docker Engine_. Estimate time: 15 mins. Go to [Get Docker](https://docs.docker.com/get-docker/), and pick Docker \[Desktop for Mac | Desktop for Windows | for Linux\] to do the appropriate install. -For Mac and Windows, after doing _Install Docker Desktop_, also run _Docker Desktop_, so as to start _Docker Engine_. For Linux, install _Docker Engine_ then start _Docker_. +For Mac and Windows, after installing Docker Desktop, find the application icon to run the _Docker_ app (_Docker Desktop_), so as to start _Docker Engine_; +it could take about half a minute to start; then you could minimize or close the Docker _Dashboard_ window but verify that _Docker Desktop_ is still running. +For Linux, install _Docker Engine_ then start _Docker_. ### How to clone GitHub repository into local directory Estimate time: 10 mins. The commands shown in the text area below do the following; the text area also shows the _Terminal_ console response to the commands: -- Clone with `git clone https://github.com/...` the specified _GitHub_ repository at a Terminal command line; this downloads the demo source code from that specified repository into your local computer +- Clone with `git clone https://github.com/...` the specified _GitHub_ repository at a Terminal command line; +this downloads the demo source code from that specified repository into your local computer - `cd DeepLearningPython35` into the repository directory; this changes your directory to the directory of the downloaded demo Python source code - Verify with `git branch` that you are on the _master_ branch of the repository; the branch you are on is marked with an asterisk (*); a repository can have many versions of the source code, each stored in its own branch -- Checkout the desired branch instead of master branch, with `git checkout chap1_30-hidden-neurons-3.0-eta`; that specified branch has the desired setup of demo code you want to run +- Checkout the desired branch instead of master branch, with `git checkout chap1_30-hidden-neurons-3.0-eta`; +that specific branch has the desired setup of demo code you want to run for this Part 1 class - Verify with `git branch` again that you are on the desired branch _chap1_30-hidden-neurons-3.0-eta_ which is now marked with an asterisk (*) ``` -~ $ _ +~ $ ~ $ git clone https://github.com/clkim/DeepLearningPython35.git ~ $ cd DeepLearningPython35 @@ -56,7 +61,7 @@ a repository can have many versions of the source code, each stored in its own b chap2_fully-matrix-based-backpropagation-mini-batch chap6 master -~/DeepLearningPython35 $ _ +~/DeepLearningPython35 $ ``` (Skip until class) To run the desired setup of demo code, "uncomment in" or "comment out" as appropriate the code in _test.py_ in order to specify the neural network and deep learning configuration to run. @@ -71,11 +76,11 @@ Acknowledgement: The repository is forked from the _DeepLearningPython35_ reposi Python 2.7 to Python 3.5 and wrote the "orchestrator" testing file _test.py_. ### How to create a Docker container locally to run the demo Python code -Background: We want to set up a "bind" type of mount in the container whose source is the directory in our local computer where the demo Python source code -has been cloned from GitHub, so that the source code on our local computer would be accessible from inside the container. +Background: We want to set up a "bind" type of mount in the container whose source is the directory in our local computer where the demo Python +source code has been cloned from GitHub, in order that the source code on our local computer would be accessible from inside the container. We also want to install two Python packages, _Numpy_ package and _Theano_ package, in the container we want to create. -Ensure that you have already started Docker Engine, e.g. by running _Docker Desktop_ app locally; +Ensure that you have already started Docker Engine, e.g. by running _Docker_ app (_Docker Desktop_) locally; and that you have already cloned the demo Python source code from GitHub, into the _DeepLearningPython35_ directory, as described above in "How to clone GitHub repository into local directory". @@ -97,7 +102,7 @@ which is a very popular data science platform - Then we exit our newly created local container, with `exit` - Back at the Terminal command line, verify that we have created a local container named _deeplearning_, with `docker container ls --all` ``` -~/DeepLearningPython35 $ _ +~/DeepLearningPython35 $ ~/DeepLearningPython35 $ docker pull continuumio/miniconda3 Using default tag: latest ... @@ -118,7 +123,6 @@ Collecting package metadata (current_repodata.json): done Proceed ([y]/n)? y ... # To activate this environment, use -# ... (base) root@xxx:/# conda activate nndlbook @@ -161,7 +165,7 @@ xxxxxxxxxxxx continuumio/miniconda3 "/bin/bash" xxx dee ### How to run the demo Python code in the created Docker container Estimate time: 10 mins. -Ensure that you have already started Docker Engine, e.g. by running _Docker Desktop_ app locally; +Ensure that you have already started Docker Engine, e.g. by running _Docker_ app (_Docker Desktop_) locally; and that you have already cloned the demo Python source code from GitHub, into the _DeepLearningPython35_ directory, as described above in "How to clone GitHub repository into local directory". @@ -176,15 +180,16 @@ The commands shown in the text area below do the following; the text area also s - At _DeepLearningPython35_ directory, start `docker` container _deeplearning_ and specifying option to attach an interactive shell, with `docker container start -ai deeplearning` - At the interactive shell command line inside the container, we `cd` into the _deeplearn_ directory mounted into the container; - we had bind the mount to the local _DeepLearningPython35_ directory, which must be already on the git branch _chap1_30-hidden-neurons-3.0-eta_ + when we created the container, we had bind that mount to the local _DeepLearningPython35_ directory, + which must be already on the git branch _chap1_30-hidden-neurons-3.0-eta_ - We check the python version, with `python --version` - And verify what conda environments we have, with `conda info --env` - - Then we activate our own conda environment _nndlbook_, with `conda activate nndlbook` - - Finally, we now run the demo code in _test.py_, with `python3.8 test.py` + - Then we activate our own previously created conda environment _nndlbook_, with `conda activate nndlbook` + - Finally, we now run the demo code in _test.py_, with `python3.8 test.py`; use control-c to break out of the run if desired - After the run, we exit the container, with `exit` - Now we should be back at the Terminal command line, in the _DeepLearningPython35_ directory ``` -~/DeepLearningPython35 $ _ +~/DeepLearningPython35 $ ~/DeepLearningPython35 $ docker container ls --all < Should see a container named "deeplearning" > CONTAINER ID IMAGE COMMAND CREATED ... NAMES @@ -210,14 +215,14 @@ Epoch 3 : 9340 / 10000 Epoch 4 : 9337 / 10000 Epoch 5 : 9374 / 10000 Epoch 6 : 9386 / 10000 -< On my late-2013 MacBook Pro, it takes about a minute to finish Epoch 6; control-C to break > +< On my late-2013 MacBook Pro, it takes about a minute to finish Epoch 6; use control-c to break if desired > < Each epoch run uses the training images; then neural network is evaluated on test images > (nndlbook) root@xxx:/deeplearn# exit exit -~/DeepLearningPython35 $ _ +~/DeepLearningPython35 $ ``` -### End of README for IEEE Boston: Introduction to Practical Neural Networks and Deep Learning (Part 1) +## End of Running IEEE Boston Section class demo code: Introduction to Practical Neural Networks and Deep Learning (Part 1) ___ ## Overview From 5dc5af5e14bb5c857ba7a1a7b5d2c9fc54c95870 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Sat, 12 Jun 2021 09:30:15 -0400 Subject: [PATCH 07/27] Improve README more --- README.md | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 585ba9e..b467e18 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ ## Running IEEE Boston Section class demo code ## Introduction to Practical Neural Networks and Deep Learning (Part 1)
June 19, 2021 - +Instructions are given below for each of the five steps: +* download Git software +* download Docker software +* clone GitHub respository containing the demo code into local directory +* create a Docker container locally to run the demo Python code +* run the demo Python code in the created Docker container ##### Why use Docker container In order to avoid potential problems with installing Python and the needed packages to run the book's demo code on different platforms such as Mac, Windows, or Linux, @@ -10,7 +15,7 @@ Docker is sufficiently popular nowadays so that installing as well as running Do ### How to download Git software Git is a very popular source code management tool for version control, widely used among software professionals. -Estimate time: 15 mins. +Estimated time: 15 mins. Go to [Install Git](https://www.atlassian.com/git/tutorials/install-git), and scroll to Install Git on \[Mac OS X | Windows | Linux\] section as appropriate. Unless you have a preference, probably just pick the first method for your platform. @@ -18,21 +23,21 @@ Unless you have a preference, probably just pick the first method for your platf Git for Mac Installer > pick latest link (currently `git-2.31.0-intel-universal-mavericks.dmg`); if you're installing from a downloaded .dmg file, you may be blocked from opening the installation package; if you see "macOS cannot verify that this app is free from malware", go to _System Preferences_ > _Security & Privacy_ > click `Open Anyway` for that downloaded git-xxx.pkg file. -Install just Git; you should not need to install git-credential-osxkeychain helper. +Install just Git; you should not need to install git-credential-osxkeychain helper.) ### How to download Docker software In software engineering parlance, a _container_ packages up code and all its dependencies into a standard unit of software so that the application can run quickly and reliably from one computing environment to another. Docker is a very popular container technology. The containers run on _Docker Engine_. -Estimate time: 15 mins. +Estimated time: 15 mins. Go to [Get Docker](https://docs.docker.com/get-docker/), and pick Docker \[Desktop for Mac | Desktop for Windows | for Linux\] to do the appropriate install. For Mac and Windows, after installing Docker Desktop, find the application icon to run the _Docker_ app (_Docker Desktop_), so as to start _Docker Engine_; it could take about half a minute to start; then you could minimize or close the Docker _Dashboard_ window but verify that _Docker Desktop_ is still running. For Linux, install _Docker Engine_ then start _Docker_. ### How to clone GitHub repository into local directory -Estimate time: 10 mins. +Estimated time: 10 mins. The commands shown in the text area below do the following; the text area also shows the _Terminal_ console response to the commands: - Clone with `git clone https://github.com/...` the specified _GitHub_ repository at a Terminal command line; this downloads the demo source code from that specified repository into your local computer @@ -69,8 +74,9 @@ the neural network and deep learning configuration to run. (Skip until class) To see an example of the (flexible but somewhat hackish and minimalist) changes I made in _test.py_ in order to run the demo in the chap1 branch, at command line run `git diff ea229ac 6ba2425` -to see the small changes committed in the branch (red text is deleted, green text is added; hit space bar once to scroll down one page; -when we see the (END) of document, enter q to quit and get back to the command line). +to see the small changes committed in the branch +(red text is deleted, green text is added; hit space bar once to scroll down one page; +when we see `(END)` of document, enter q to quit and get back to the command line). Acknowledgement: The repository is forked from the _DeepLearningPython35_ repository of _Michal Daniel Dobrzanski_ who ported the book's code from Python 2.7 to Python 3.5 and wrote the "orchestrator" testing file _test.py_. @@ -86,21 +92,21 @@ as described above in "How to clone GitHub repository into local directory". `cd` into the directory _DeepLearningPython35_ if not already there. -Estimate time: 15 - 30 mins. +Estimated time: 20 - 30 mins. The commands shown in the text area below do the following; the text area also shows the _Terminal_ console response to the commands: - First run `docker pull continuumio/miniconda3` to download the _miniconda3_ image, which contains _conda_, a small version of Anaconda which is a very popular data science platform - Then run `docker images` to verify the image _continuumio/miniconda3_ is downloaded - Then run the given `docker` command to create a new container layer over the downloaded image - At the interactive shell command line inside the container, we check the conda version, with `conda --version` - - Then create our own environment, named _nndlbook_ for our own use, with `conda create --nndlbook` - - Then we active this new _nndlbook_ conda environment, with `conda activate nndlbook` - - Next, do a perfunctory check that no additional packages are installed yet, with `conda list` - - Do a check that we do have python installed already, with `python --version` + - Then create our own environment, named _nndlbook_ for our use, with `conda create --nndlbook` + - Then we activate this new _nndlbook_ conda environment, with `conda activate nndlbook` + - Next, do a confirming check that no additional packages are installed yet, with `conda list` + - And do a check that we do have python installed already, with `python --version` - Now, we are ready to install our packages, with `conda install numpy` and then `conda install theano` - - Finally, we do a check that we see those two package names, among others, with `conda list` + - Finally, we do a sanity check that we see those two package names, among others, with `conda list` - Then we exit our newly created local container, with `exit` -- Back at the Terminal command line, verify that we have created a local container named _deeplearning_, with `docker container ls --all` +- Back at the Terminal console, verify that we have created a local container named _deeplearning_, with `docker container ls --all` ``` ~/DeepLearningPython35 $ ~/DeepLearningPython35 $ docker pull continuumio/miniconda3 @@ -164,7 +170,7 @@ xxxxxxxxxxxx continuumio/miniconda3 "/bin/bash" xxx dee ``` ### How to run the demo Python code in the created Docker container -Estimate time: 10 mins. +Estimated time: 10 mins. Ensure that you have already started Docker Engine, e.g. by running _Docker_ app (_Docker Desktop_) locally; and that you have already cloned the demo Python source code from GitHub, into the _DeepLearningPython35_ directory, as described above in "How to clone GitHub repository into local directory". @@ -187,7 +193,7 @@ The commands shown in the text area below do the following; the text area also s - Then we activate our own previously created conda environment _nndlbook_, with `conda activate nndlbook` - Finally, we now run the demo code in _test.py_, with `python3.8 test.py`; use control-c to break out of the run if desired - After the run, we exit the container, with `exit` -- Now we should be back at the Terminal command line, in the _DeepLearningPython35_ directory +- Now we should be back at the Terminal console, in the _DeepLearningPython35_ directory ``` ~/DeepLearningPython35 $ ~/DeepLearningPython35 $ docker container ls --all From ac23e9d11be7368057a4061f4638618b51ea2cc0 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Wed, 8 Sep 2021 21:42:55 -0400 Subject: [PATCH 08/27] update README next class date --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b467e18..ce56311 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ## Running IEEE Boston Section class demo code -## Introduction to Practical Neural Networks and Deep Learning (Part 1)
June 19, 2021 +## Introduction to Practical Neural Networks and Deep Learning (Part 1)
September 18, 2021 Instructions are given below for each of the five steps: * download Git software * download Docker software From 243a2023b5538d5d0d59ba4e1db2d20f78173e6e Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Fri, 17 Sep 2021 01:05:47 -0400 Subject: [PATCH 09/27] update README: latest git version, docker for personal use is still free, minor editing --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ce56311..0acc21e 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Go to [Install Git](https://www.atlassian.com/git/tutorials/install-git), and sc Unless you have a preference, probably just pick the first method for your platform. (For Mac: -Git for Mac Installer > pick latest link (currently `git-2.31.0-intel-universal-mavericks.dmg`); +Git for Mac Installer > pick latest link (currently `git-2.33.0-intel-universal-mavericks.dmg`); if you're installing from a downloaded .dmg file, you may be blocked from opening the installation package; if you see "macOS cannot verify that this app is free from malware", go to _System Preferences_ > _Security & Privacy_ > click `Open Anyway` for that downloaded git-xxx.pkg file. Install just Git; you should not need to install git-credential-osxkeychain helper.) @@ -28,12 +28,12 @@ Install just Git; you should not need to install git-credential-osxkeychain help ### How to download Docker software In software engineering parlance, a _container_ packages up code and all its dependencies into a standard unit of software so that the application can run quickly and reliably from one computing environment to another. -Docker is a very popular container technology. The containers run on _Docker Engine_. +Docker is a very popular container technology. Personal use will remain free. The containers run on _Docker Engine_. Estimated time: 15 mins. Go to [Get Docker](https://docs.docker.com/get-docker/), and pick Docker \[Desktop for Mac | Desktop for Windows | for Linux\] to do the appropriate install. For Mac and Windows, after installing Docker Desktop, find the application icon to run the _Docker_ app (_Docker Desktop_), so as to start _Docker Engine_; -it could take about half a minute to start; then you could minimize or close the Docker _Dashboard_ window but verify that _Docker Desktop_ is still running. +it could take about half a minute to start; then you could minimize or close the Docker _Dashboard_ window (double check that _Docker Desktop_ is still running). For Linux, install _Docker Engine_ then start _Docker_. ### How to clone GitHub repository into local directory From 7f5f9efb070039da193937dce10aa2a13a8a4349 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Sat, 18 Sep 2021 19:15:47 -0400 Subject: [PATCH 10/27] update REDME to reflect latest miniconda version which has Python 3.9; remove instructions to install Theano package does not seem compatible with Python 3.9 --- README.md | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 0acc21e..e19d02f 100644 --- a/README.md +++ b/README.md @@ -82,14 +82,15 @@ Acknowledgement: The repository is forked from the _DeepLearningPython35_ reposi Python 2.7 to Python 3.5 and wrote the "orchestrator" testing file _test.py_. ### How to create a Docker container locally to run the demo Python code -Background: We want to set up a "bind" type of mount in the container whose source is the directory in our local computer where the demo Python +Background: We want to set up a `bind mount` in the container whose source is the directory in our local computer where the demo Python source code has been cloned from GitHub, in order that the source code on our local computer would be accessible from inside the container. -We also want to install two Python packages, _Numpy_ package and _Theano_ package, in the container we want to create. +We also want to install the Python packages _Numpy_ package in the container we want to create. Ensure that you have already started Docker Engine, e.g. by running _Docker_ app (_Docker Desktop_) locally; and that you have already cloned the demo Python source code from GitHub, into the _DeepLearningPython35_ directory, as described above in "How to clone GitHub repository into local directory". +You must be at the _DeepLearningPython35_ directory, because the `bind mount` being set up into the container references `pwd`, the current directory. `cd` into the directory _DeepLearningPython35_ if not already there. Estimated time: 20 - 30 mins. @@ -101,10 +102,10 @@ which is a very popular data science platform - At the interactive shell command line inside the container, we check the conda version, with `conda --version` - Then create our own environment, named _nndlbook_ for our use, with `conda create --nndlbook` - Then we activate this new _nndlbook_ conda environment, with `conda activate nndlbook` - - Next, do a confirming check that no additional packages are installed yet, with `conda list` + - Next, do a confirming check that no packages are installed yet, with `conda list` - And do a check that we do have python installed already, with `python --version` - - Now, we are ready to install our packages, with `conda install numpy` and then `conda install theano` - - Finally, we do a sanity check that we see those two package names, among others, with `conda list` + - Now, we are ready to install our package, with `conda install numpy` + - Finally, we do a sanity check that we see the package names, among others, with `conda list` - Then we exit our newly created local container, with `exit` - Back at the Terminal console, verify that we have created a local container named _deeplearning_, with `docker container ls --all` ``` @@ -121,14 +122,14 @@ continuumio/miniconda3 latest xxxxxxxxxxxx n months ago nnnMB ~/DeepLearningPython35 $ docker run -it --name deeplearning --mount type=bind,source="$(pwd)",target=/deeplearn continuumio/miniconda3 (base) root@xxx:/# conda --version -conda 4.9.2 +conda 4.10.3 (base) root@xxx:/# conda create --name nndlbook Collecting package metadata (current_repodata.json): done ... Proceed ([y]/n)? y ... -# To activate this environment, use +Executing transaction: done ... (base) root@xxx:/# conda activate nndlbook @@ -139,7 +140,7 @@ Proceed ([y]/n)? y # Name Version Build Channel (nndlbook) root@xxx:/# python --version -Python 3.8.5 +Python 3.9.5 (nndlbook) root@x:/# conda install numpy Collecting package metadata (current_repodata.json): done @@ -149,16 +150,8 @@ Proceed ([y]/n)? y ... Executing transaction: done -(nndlbook) root@xxx:/# conda install theano -Collecting package metadata (current_repodata.json): done -... -Proceed ([y]/n)? y -... -... -Executing transaction: done - (nndlbook) root@xxx:/# conda list -< Should see list of packages including numpy and theano > +< Should see list of packages including numpy and numpy-base > (nndlbook) root@xxx:/# exit exit @@ -206,14 +199,14 @@ xxxxxxxxxxxx continuumio/miniconda3 "/bin/bash" xxx dee (base) root@xxx:/# cd deeplearn/ (base) root@xxx:/deeplearn# python --version -Python 3.8.5 +Python 3.9.5 (base) root@xxx:/deeplearn# conda info --env < Should see two environments: base and nndlbook > (base) root@xxx:/deeplearn# conda activate nndlbook -(nndlbook) root@xxx:/deeplearn# python3.8 test.py +(nndlbook) root@xxx:/deeplearn# python3.9 test.py Epoch 0 : 8943 / 10000 Epoch 1 : 9166 / 10000 Epoch 2 : 9267 / 10000 @@ -221,7 +214,7 @@ Epoch 3 : 9340 / 10000 Epoch 4 : 9337 / 10000 Epoch 5 : 9374 / 10000 Epoch 6 : 9386 / 10000 -< On my late-2013 MacBook Pro, it takes about a minute to finish Epoch 6; use control-c to break if desired > +< On my late-2013 MacBook Pro, it takes about a minute to do Eposh 1 to Epoch 6; use control-c to break if desired > < Each epoch run uses the training images; then neural network is evaluated on test images > (nndlbook) root@xxx:/deeplearn# exit From e4d3ce95102943abdd57b27124dff37a2803215b Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Sat, 18 Sep 2021 19:23:17 -0400 Subject: [PATCH 11/27] fix typo 'python3.9 test.py' --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e19d02f..72949ba 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ The commands shown in the text area below do the following; the text area also s - We check the python version, with `python --version` - And verify what conda environments we have, with `conda info --env` - Then we activate our own previously created conda environment _nndlbook_, with `conda activate nndlbook` - - Finally, we now run the demo code in _test.py_, with `python3.8 test.py`; use control-c to break out of the run if desired + - Finally, we now run the demo code in _test.py_, with `python3.9 test.py`; use control-c to break out of the run if desired - After the run, we exit the container, with `exit` - Now we should be back at the Terminal console, in the _DeepLearningPython35_ directory ``` From 87169b35d3b0280c01b0ecbeddd480381ddb6d09 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Mon, 28 Feb 2022 01:23:41 -0500 Subject: [PATCH 12/27] update README info relating to Docker; update next class date --- README.md | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 72949ba..020db4b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ## Running IEEE Boston Section class demo code -## Introduction to Practical Neural Networks and Deep Learning (Part 1)
September 18, 2021 +## Introduction to Practical Neural Networks and Deep Learning (Part 1)
March 19, 2022 Instructions are given below for each of the five steps: * download Git software * download Docker software @@ -10,7 +10,8 @@ Instructions are given below for each of the five steps: ##### Why use Docker container In order to avoid potential problems with installing Python and the needed packages to run the book's demo code on different platforms such as Mac, Windows, or Linux, we decided to create a _Docker_ container and to run the demo code in it. -Docker is sufficiently popular nowadays so that installing as well as running Docker on different platforms should be well supported and documented. +Docker is sufficiently popular nowadays so that installing as well as running Docker on different platforms should be well supported and documented. +Personal and small business use is still free, though a sign-up for a Docker account may be required. ### How to download Git software Git is a very popular source code management tool for version control, widely used among software professionals. @@ -28,7 +29,7 @@ Install just Git; you should not need to install git-credential-osxkeychain help ### How to download Docker software In software engineering parlance, a _container_ packages up code and all its dependencies into a standard unit of software so that the application can run quickly and reliably from one computing environment to another. -Docker is a very popular container technology. Personal use will remain free. The containers run on _Docker Engine_. +Docker is a very popular container technology. The containers run on _Docker Engine_. Estimated time: 15 mins. Go to [Get Docker](https://docs.docker.com/get-docker/), and pick Docker \[Desktop for Mac | Desktop for Windows | for Linux\] to do the appropriate install. @@ -95,18 +96,20 @@ You must be at the _DeepLearningPython35_ directory, because the `bind mount` be Estimated time: 20 - 30 mins. The commands shown in the text area below do the following; the text area also shows the _Terminal_ console response to the commands: -- First run `docker pull continuumio/miniconda3` to download the _miniconda3_ image, which contains _conda_, a small version of Anaconda +- First run `docker pull continuumio/miniconda3` to download the _miniconda3_ image which contains _conda_, a small version of Anaconda which is a very popular data science platform - Then run `docker images` to verify the image _continuumio/miniconda3_ is downloaded - Then run the given `docker` command to create a new container layer over the downloaded image - At the interactive shell command line inside the container, we check the conda version, with `conda --version` - Then create our own environment, named _nndlbook_ for our use, with `conda create --nndlbook` + - (May be prompted to update to a new version of conda) - Then we activate this new _nndlbook_ conda environment, with `conda activate nndlbook` - Next, do a confirming check that no packages are installed yet, with `conda list` - And do a check that we do have python installed already, with `python --version` - Now, we are ready to install our package, with `conda install numpy` - - Finally, we do a sanity check that we see the package names, among others, with `conda list` - - Then we exit our newly created local container, with `exit` + - We do a sanity check that we see the `numpy` package name, among others, with `conda list` + - Finally, we check the python version which may be different after installing `numpy` + - We exit our newly created local container, with `exit` - Back at the Terminal console, verify that we have created a local container named _deeplearning_, with `docker container ls --all` ``` ~/DeepLearningPython35 $ @@ -127,6 +130,11 @@ conda 4.10.3 (base) root@xxx:/# conda create --name nndlbook Collecting package metadata (current_repodata.json): done ... +(if see ==> WARNING: A newer version of conda exists. <== ) +(exit the create by entering n at prompt to Proceed ) +(then update conda by running the suggested at command prompt #: conda update -n base -c defaults conda ) +(answer y to proceed ) +(now re-run at command prompt #: conda create --name nndlbook ) Proceed ([y]/n)? y ... Executing transaction: done @@ -153,6 +161,10 @@ Executing transaction: done (nndlbook) root@xxx:/# conda list < Should see list of packages including numpy and numpy-base > +(nndlbook) root@xxx:/# python --version +Python 3.9.7 +(note that we have a later Python version after installing Numpy ) + (nndlbook) root@xxx:/# exit exit @@ -181,9 +193,9 @@ The commands shown in the text area below do the following; the text area also s - At the interactive shell command line inside the container, we `cd` into the _deeplearn_ directory mounted into the container; when we created the container, we had bind that mount to the local _DeepLearningPython35_ directory, which must be already on the git branch _chap1_30-hidden-neurons-3.0-eta_ - - We check the python version, with `python --version` - And verify what conda environments we have, with `conda info --env` - Then we activate our own previously created conda environment _nndlbook_, with `conda activate nndlbook` + - We check the python version, with `python --version` - Finally, we now run the demo code in _test.py_, with `python3.9 test.py`; use control-c to break out of the run if desired - After the run, we exit the container, with `exit` - Now we should be back at the Terminal console, in the _DeepLearningPython35_ directory @@ -198,14 +210,14 @@ xxxxxxxxxxxx continuumio/miniconda3 "/bin/bash" xxx dee (base) root@xxx:/# cd deeplearn/ -(base) root@xxx:/deeplearn# python --version -Python 3.9.5 - (base) root@xxx:/deeplearn# conda info --env < Should see two environments: base and nndlbook > (base) root@xxx:/deeplearn# conda activate nndlbook +(nndlbook) root@xxx:/deeplearn# python --version +Python 3.9.7 + (nndlbook) root@xxx:/deeplearn# python3.9 test.py Epoch 0 : 8943 / 10000 Epoch 1 : 9166 / 10000 From 4f95dd0ebc4acdebb917afabf31b2d32dabe404a Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Mon, 28 Feb 2022 01:52:57 -0500 Subject: [PATCH 13/27] improve the README, fix an earlier typo --- README.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 020db4b..7b2b614 100644 --- a/README.md +++ b/README.md @@ -130,16 +130,22 @@ conda 4.10.3 (base) root@xxx:/# conda create --name nndlbook Collecting package metadata (current_repodata.json): done ... -(if see ==> WARNING: A newer version of conda exists. <== ) -(exit the create by entering n at prompt to Proceed ) -(then update conda by running the suggested at command prompt #: conda update -n base -c defaults conda ) -(answer y to proceed ) -(now re-run at command prompt #: conda create --name nndlbook ) +< if see ==> WARNING: A newer version of conda exists. <== > + current version: 4.10.3 + latest version: 4.11.0 +< exit the 'conda create' command by entering n at prompt to Proceed > +< then update conda by running the suggested command at prompt #: > +< conda update -n base -c defaults conda > +< answer y to proceed > +< then re-run at command prompt #: conda create --name nndlbook > Proceed ([y]/n)? y ... Executing transaction: done ... +(base) root@xxx:/# conda --version +conda 4.11.0 + (base) root@xxx:/# conda activate nndlbook (nndlbook) root@xxx:/# conda list @@ -163,7 +169,7 @@ Executing transaction: done (nndlbook) root@xxx:/# python --version Python 3.9.7 -(note that we have a later Python version after installing Numpy ) +< note that we have a later Python version after installing Numpy > (nndlbook) root@xxx:/# exit exit @@ -226,7 +232,7 @@ Epoch 3 : 9340 / 10000 Epoch 4 : 9337 / 10000 Epoch 5 : 9374 / 10000 Epoch 6 : 9386 / 10000 -< On my late-2013 MacBook Pro, it takes about a minute to do Eposh 1 to Epoch 6; use control-c to break if desired > +< On my late-2013 MacBook Pro, it takes about a minute to do Epoch 1 to Epoch 6; use control-c to break if desired > < Each epoch run uses the training images; then neural network is evaluated on test images > (nndlbook) root@xxx:/deeplearn# exit From 08f5ad8461f3891f89fd8018e3d69046c697e64b Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Sun, 6 Mar 2022 15:13:57 -0500 Subject: [PATCH 14/27] more README editing --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 7b2b614..536d249 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,9 @@ Instructions are given below for each of the five steps: ##### Why use Docker container In order to avoid potential problems with installing Python and the needed packages to run the book's demo code on different platforms such as Mac, Windows, or Linux, -we decided to create a _Docker_ container and to run the demo code in it. +we decided to create a _Docker_ container and to run the demo code in it. +In software engineering parlance, a _container_ packages up code and all its dependencies into a standard unit of software so that the application can run +anywhere, as long as the container engine supports the underlying operating system. Docker is sufficiently popular nowadays so that installing as well as running Docker on different platforms should be well supported and documented. Personal and small business use is still free, though a sign-up for a Docker account may be required. @@ -27,8 +29,6 @@ if you're installing from a downloaded .dmg file, you may be blocked from openin Install just Git; you should not need to install git-credential-osxkeychain helper.) ### How to download Docker software -In software engineering parlance, a _container_ packages up code and all its dependencies into a standard unit of software so that the application can run -quickly and reliably from one computing environment to another. Docker is a very popular container technology. The containers run on _Docker Engine_. Estimated time: 15 mins. @@ -85,7 +85,7 @@ Python 2.7 to Python 3.5 and wrote the "orchestrator" testing file _test.py_. ### How to create a Docker container locally to run the demo Python code Background: We want to set up a `bind mount` in the container whose source is the directory in our local computer where the demo Python source code has been cloned from GitHub, in order that the source code on our local computer would be accessible from inside the container. -We also want to install the Python packages _Numpy_ package in the container we want to create. +We also want to install the Python package _Numpy_ in the container we want to create. Ensure that you have already started Docker Engine, e.g. by running _Docker_ app (_Docker Desktop_) locally; and that you have already cloned the demo Python source code from GitHub, into the _DeepLearningPython35_ directory, @@ -96,8 +96,8 @@ You must be at the _DeepLearningPython35_ directory, because the `bind mount` be Estimated time: 20 - 30 mins. The commands shown in the text area below do the following; the text area also shows the _Terminal_ console response to the commands: -- First run `docker pull continuumio/miniconda3` to download the _miniconda3_ image which contains _conda_, a small version of Anaconda -which is a very popular data science platform +- First run `docker pull continuumio/miniconda3` to download the _miniconda3_ image which contains Python and _conda_, a package manager as well as +an environment manager tool; miniconda can be considered a mini version of Anaconda which is a very popular data science platform - Then run `docker images` to verify the image _continuumio/miniconda3_ is downloaded - Then run the given `docker` command to create a new container layer over the downloaded image - At the interactive shell command line inside the container, we check the conda version, with `conda --version` @@ -105,10 +105,10 @@ which is a very popular data science platform - (May be prompted to update to a new version of conda) - Then we activate this new _nndlbook_ conda environment, with `conda activate nndlbook` - Next, do a confirming check that no packages are installed yet, with `conda list` - - And do a check that we do have python installed already, with `python --version` + - And do a sanity check that we do have python installed, with `python --version` - Now, we are ready to install our package, with `conda install numpy` - We do a sanity check that we see the `numpy` package name, among others, with `conda list` - - Finally, we check the python version which may be different after installing `numpy` + - Finally, we check the python version which may be different in our _nndlbook_ environment after installing `numpy` - We exit our newly created local container, with `exit` - Back at the Terminal console, verify that we have created a local container named _deeplearning_, with `docker container ls --all` ``` @@ -130,14 +130,14 @@ conda 4.10.3 (base) root@xxx:/# conda create --name nndlbook Collecting package metadata (current_repodata.json): done ... -< if see ==> WARNING: A newer version of conda exists. <== > - current version: 4.10.3 - latest version: 4.11.0 +< if see ==> WARNING: A newer version of conda exists. <== > +< current version: 4.10.3 > +< latest version: 4.11.0 > < exit the 'conda create' command by entering n at prompt to Proceed > -< then update conda by running the suggested command at prompt #: > -< conda update -n base -c defaults conda > -< answer y to proceed > -< then re-run at command prompt #: conda create --name nndlbook > +< then update conda by running the suggested command at prompt #: > +< conda update -n base -c defaults conda > +< answer y to proceed > +< then re-run at command prompt #: conda create --name nndlbook > Proceed ([y]/n)? y ... Executing transaction: done From 61cb2c957d0854aa7730dd73d3ce6ab31da6af29 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Fri, 10 Mar 2023 18:42:42 -0500 Subject: [PATCH 15/27] update README for Mar 18, 2023, class --- README.md | 70 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 536d249..1225cfa 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ## Running IEEE Boston Section class demo code -## Introduction to Practical Neural Networks and Deep Learning (Part 1)
March 19, 2022 +## Introduction to Practical Neural Networks and Deep Learning (Part 1)
March 18, 2023 Instructions are given below for each of the five steps: * download Git software * download Docker software @@ -20,22 +20,25 @@ Git is a very popular source code management tool for version control, widely us Estimated time: 15 mins. Go to [Install Git](https://www.atlassian.com/git/tutorials/install-git), and scroll to Install Git on \[Mac OS X | Windows | Linux\] section as appropriate. -Unless you have a preference, probably just pick the first method for your platform. +Unless you have a preference, you should probably just pick the first method for your platform. (For Mac: Git for Mac Installer > pick latest link (currently `git-2.33.0-intel-universal-mavericks.dmg`); -if you're installing from a downloaded .dmg file, you may be blocked from opening the installation package; if you see -"macOS cannot verify that this app is free from malware", go to _System Preferences_ > _Security & Privacy_ > click `Open Anyway` for that downloaded git-xxx.pkg file. +This version is more than a year old but for our purposes is perfectly ok. +If you want the latest version, go to [Git - Download for macOS](https://git-scm.com/download/mac) and follow instructions for your option, e.g. Homebrew or MacPorts. +If you're installing from a downloaded .dmg file, you may be blocked from opening the installation package; if you see something like +"macOS cannot verify that this app is free from malware", go to _System Preferences_ > _Security & Privacy_ > _General_ tab, click the lock icon in lower corner to Unlock, +then under `Allow apps downloaded from` | `App Store and identified developers` > `Allow` that downloaded git-xxx.pkg file, if you're sure it is safe. Install just Git; you should not need to install git-credential-osxkeychain helper.) ### How to download Docker software Docker is a very popular container technology. The containers run on _Docker Engine_. Estimated time: 15 mins. -Go to [Get Docker](https://docs.docker.com/get-docker/), and pick Docker \[Desktop for Mac | Desktop for Windows | for Linux\] to do the appropriate install. -For Mac and Windows, after installing Docker Desktop, find the application icon to run the _Docker_ app (_Docker Desktop_), so as to start _Docker Engine_; -it could take about half a minute to start; then you could minimize or close the Docker _Dashboard_ window (double check that _Docker Desktop_ is still running). -For Linux, install _Docker Engine_ then start _Docker_. +Go to [Get Docker](https://docs.docker.com/get-docker/), and pick Docker Desktop for \[Mac | Windows | Linux\] to do the appropriate install. +After installing Docker Desktop, find the application icon to run the _Docker_ app (_Docker Desktop_), so as to start _Docker Engine_; +it could take about half a minute for _Docker Desktop_ window to start and open; then you could minimize or close that window (double check that _Docker Desktop_ +is still running). ### How to clone GitHub repository into local directory Estimated time: 10 mins. @@ -48,6 +51,7 @@ a repository can have many versions of the source code, each stored in its own b - Checkout the desired branch instead of master branch, with `git checkout chap1_30-hidden-neurons-3.0-eta`; that specific branch has the desired setup of demo code you want to run for this Part 1 class - Verify with `git branch` again that you are on the desired branch _chap1_30-hidden-neurons-3.0-eta_ which is now marked with an asterisk (*) +- Use `ls -l` to see the files in the directory ``` ~ $ ~ $ git clone https://github.com/clkim/DeepLearningPython35.git @@ -67,6 +71,18 @@ that specific branch has the desired setup of demo code you want to run for this chap2_fully-matrix-based-backpropagation-mini-batch chap6 master + +~/DeepLearningPython35 $ ls -l +total 158088 +-rw-r--r-- 1 clkim staff 492526 Feb 29 2020 MyNetwork +-rw-r--r-- 1 clkim staff 14338 Mar 10 17:04 README.md +... +... +-rw-r--r-- 1 clkim staff 770 Feb 29 2020 mnist_svm.py +-rw-r--r-- 1 clkim staff 6398 Mar 11 2021 network.py +-rw-r--r-- 1 clkim staff 15252 Feb 29 2020 network2.py +-rw-r--r--@ 1 clkim staff 13000 Feb 29 2020 network3.py +-rw-r--r-- 1 clkim staff 7394 Mar 8 23:34 test.py ~/DeepLearningPython35 $ ``` (Skip until class) To run the desired setup of demo code, "uncomment in" or "comment out" as appropriate the code in _test.py_ in order to specify @@ -76,7 +92,7 @@ the neural network and deep learning configuration to run. in the chap1 branch, at command line run `git diff ea229ac 6ba2425` to see the small changes committed in the branch -(red text is deleted, green text is added; hit space bar once to scroll down one page; +(red is for text deleted, green is for text added; hit space bar once to scroll down one page; when we see `(END)` of document, enter q to quit and get back to the command line). Acknowledgement: The repository is forked from the _DeepLearningPython35_ repository of _Michal Daniel Dobrzanski_ who ported the book's code from @@ -87,11 +103,11 @@ Background: We want to set up a `bind mount` in the container whose source is th source code has been cloned from GitHub, in order that the source code on our local computer would be accessible from inside the container. We also want to install the Python package _Numpy_ in the container we want to create. -Ensure that you have already started Docker Engine, e.g. by running _Docker_ app (_Docker Desktop_) locally; +Ensure that you have already started Docker Engine by running _Docker_ app (_Docker Desktop_) locally; and that you have already cloned the demo Python source code from GitHub, into the _DeepLearningPython35_ directory, as described above in "How to clone GitHub repository into local directory". -You must be at the _DeepLearningPython35_ directory, because the `bind mount` being set up into the container references `pwd`, the current directory. +You must be at the _DeepLearningPython35_ directory, because the `bind mount` being set up into the container calls `pwd` to get name of the current directory. `cd` into the directory _DeepLearningPython35_ if not already there. Estimated time: 20 - 30 mins. @@ -101,8 +117,8 @@ an environment manager tool; miniconda can be considered a mini version of Anaco - Then run `docker images` to verify the image _continuumio/miniconda3_ is downloaded - Then run the given `docker` command to create a new container layer over the downloaded image - At the interactive shell command line inside the container, we check the conda version, with `conda --version` - - Then create our own environment, named _nndlbook_ for our use, with `conda create --nndlbook` - - (May be prompted to update to a new version of conda) + - Then create our own environment, named _nndlbook_ for our use, with `conda create --name nndlbook` + - (May be prompted to update to a new version of conda; if so, go ahead and follow the prompts to update) - Then we activate this new _nndlbook_ conda environment, with `conda activate nndlbook` - Next, do a confirming check that no packages are installed yet, with `conda list` - And do a sanity check that we do have python installed, with `python --version` @@ -125,26 +141,18 @@ continuumio/miniconda3 latest xxxxxxxxxxxx n months ago nnnMB ~/DeepLearningPython35 $ docker run -it --name deeplearning --mount type=bind,source="$(pwd)",target=/deeplearn continuumio/miniconda3 (base) root@xxx:/# conda --version -conda 4.10.3 +conda 22.11.1 (base) root@xxx:/# conda create --name nndlbook Collecting package metadata (current_repodata.json): done ... -< if see ==> WARNING: A newer version of conda exists. <== > -< current version: 4.10.3 > -< latest version: 4.11.0 > -< exit the 'conda create' command by entering n at prompt to Proceed > -< then update conda by running the suggested command at prompt #: > -< conda update -n base -c defaults conda > -< answer y to proceed > -< then re-run at command prompt #: conda create --name nndlbook > Proceed ([y]/n)? y ... Executing transaction: done ... (base) root@xxx:/# conda --version -conda 4.11.0 +conda 22.11.1 (base) root@xxx:/# conda activate nndlbook @@ -154,22 +162,21 @@ conda 4.11.0 # Name Version Build Channel (nndlbook) root@xxx:/# python --version -Python 3.9.5 +Python 3.10.8 (nndlbook) root@x:/# conda install numpy Collecting package metadata (current_repodata.json): done ... Proceed ([y]/n)? y ... -... Executing transaction: done (nndlbook) root@xxx:/# conda list < Should see list of packages including numpy and numpy-base > (nndlbook) root@xxx:/# python --version -Python 3.9.7 -< note that we have a later Python version after installing Numpy > +Python 3.10.8 +< No change; sometimes we get a later Python version after installing Numpy > (nndlbook) root@xxx:/# exit exit @@ -194,7 +201,7 @@ If not, do `git checkout chap1_30-hidden-neurons-3.0-eta` to switch to that bran The commands shown in the text area below do the following; the text area also shows the _Terminal_ console response to the commands: - First, just verify we see the newly created container named _deeplearning_ -- At _DeepLearningPython35_ directory, start `docker` container _deeplearning_ and specifying option to attach an interactive shell, +- At _DeepLearningPython35_ directory, start `docker` container _deeplearning_ and specify option to attach an interactive shell, with `docker container start -ai deeplearning` - At the interactive shell command line inside the container, we `cd` into the _deeplearn_ directory mounted into the container; when we created the container, we had bind that mount to the local _DeepLearningPython35_ directory, @@ -202,7 +209,7 @@ The commands shown in the text area below do the following; the text area also s - And verify what conda environments we have, with `conda info --env` - Then we activate our own previously created conda environment _nndlbook_, with `conda activate nndlbook` - We check the python version, with `python --version` - - Finally, we now run the demo code in _test.py_, with `python3.9 test.py`; use control-c to break out of the run if desired + - Finally, we now run the demo code in _test.py_, with `python3.xxx test.py`; use control-c to break out of the run if desired - After the run, we exit the container, with `exit` - Now we should be back at the Terminal console, in the _DeepLearningPython35_ directory ``` @@ -222,9 +229,9 @@ xxxxxxxxxxxx continuumio/miniconda3 "/bin/bash" xxx dee (base) root@xxx:/deeplearn# conda activate nndlbook (nndlbook) root@xxx:/deeplearn# python --version -Python 3.9.7 +Python 3.10.8 -(nndlbook) root@xxx:/deeplearn# python3.9 test.py +(nndlbook) root@xxx:/deeplearn# python3.10 test.py Epoch 0 : 8943 / 10000 Epoch 1 : 9166 / 10000 Epoch 2 : 9267 / 10000 @@ -232,6 +239,7 @@ Epoch 3 : 9340 / 10000 Epoch 4 : 9337 / 10000 Epoch 5 : 9374 / 10000 Epoch 6 : 9386 / 10000 +... < On my late-2013 MacBook Pro, it takes about a minute to do Epoch 1 to Epoch 6; use control-c to break if desired > < Each epoch run uses the training images; then neural network is evaluated on test images > From 8f5b13ce0c6a4b029c73a1aee3cb2e1e74fb0367 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Fri, 4 Aug 2023 02:36:50 -0400 Subject: [PATCH 16/27] Much simpler creating Docker container by downloading anaconda3 instead of miniconda3, don't need to install numpy; update README --- README.md | 123 +++++++++++++++++++++--------------------------------- 1 file changed, 48 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index 1225cfa..26090fd 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,6 @@ Python 2.7 to Python 3.5 and wrote the "orchestrator" testing file _test.py_. ### How to create a Docker container locally to run the demo Python code Background: We want to set up a `bind mount` in the container whose source is the directory in our local computer where the demo Python source code has been cloned from GitHub, in order that the source code on our local computer would be accessible from inside the container. -We also want to install the Python package _Numpy_ in the container we want to create. Ensure that you have already started Docker Engine by running _Docker_ app (_Docker Desktop_) locally; and that you have already cloned the demo Python source code from GitHub, into the _DeepLearningPython35_ directory, @@ -110,81 +109,51 @@ as described above in "How to clone GitHub repository into local directory". You must be at the _DeepLearningPython35_ directory, because the `bind mount` being set up into the container calls `pwd` to get name of the current directory. `cd` into the directory _DeepLearningPython35_ if not already there. -Estimated time: 20 - 30 mins. +Estimated time: 10 mins. The commands shown in the text area below do the following; the text area also shows the _Terminal_ console response to the commands: -- First run `docker pull continuumio/miniconda3` to download the _miniconda3_ image which contains Python and _conda_, a package manager as well as -an environment manager tool; miniconda can be considered a mini version of Anaconda which is a very popular data science platform -- Then run `docker images` to verify the image _continuumio/miniconda3_ is downloaded +- First run `docker pull continuumio/anaconda3` to download the _Anaconda_ image (based on Python 3.X), which has the _conda_, a package manager as well as +an environment manager tool; Anaconda is a very popular data science platform; the download is from the Docker hub [docker-anaconda](https://hub.docker.com/r/continuumio/anaconda3) +- Then run `docker image ls` to verify the image _continuumio/anaconda3_ (with Tag _latest_) is downloaded - Then run the given `docker` command to create a new container layer over the downloaded image - - At the interactive shell command line inside the container, we check the conda version, with `conda --version` - - Then create our own environment, named _nndlbook_ for our use, with `conda create --name nndlbook` + - At the interactive shell command line inside the container, we can look for the conda version, with `conda --version` - (May be prompted to update to a new version of conda; if so, go ahead and follow the prompts to update) - - Then we activate this new _nndlbook_ conda environment, with `conda activate nndlbook` - - Next, do a confirming check that no packages are installed yet, with `conda list` + - Do a confirming check that the Python package _Numpy_ is installed, with `conda list | grep numpy` + - Should see the _numpy_ related packages - And do a sanity check that we do have python installed, with `python --version` - - Now, we are ready to install our package, with `conda install numpy` - - We do a sanity check that we see the `numpy` package name, among others, with `conda list` - - Finally, we check the python version which may be different in our _nndlbook_ environment after installing `numpy` - - We exit our newly created local container, with `exit` + - (Extra credit: we can use _conda_ to install packages, with `conda install packagename`) + - Ok, exit our newly created local container, with `exit` - Back at the Terminal console, verify that we have created a local container named _deeplearning_, with `docker container ls --all` ``` ~/DeepLearningPython35 $ -~/DeepLearningPython35 $ docker pull continuumio/miniconda3 +~/DeepLearningPython35 $ docker pull continuumio/anaconda3 Using default tag: latest ... -docker.io/continuumio/miniconda3:latest +docker.io/continuumio/anaconda3:latest -~/DeepLearningPython35 $ docker images +~/DeepLearningPython35 $ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE -continuumio/miniconda3 latest xxxxxxxxxxxx n months ago nnnMB - -~/DeepLearningPython35 $ docker run -it --name deeplearning --mount type=bind,source="$(pwd)",target=/deeplearn continuumio/miniconda3 - -(base) root@xxx:/# conda --version -conda 22.11.1 +continuumio/anaconda3 latest xxxxxxxxxxxx n months ago n.nnGB -(base) root@xxx:/# conda create --name nndlbook -Collecting package metadata (current_repodata.json): done -... -Proceed ([y]/n)? y -... -Executing transaction: done -... +~/DeepLearningPython35 $ docker run -it --name deeplearning --mount type=bind,source="$(pwd)",target=/deeplearn continuumio/anaconda3 +(base) root@xxx:/# (base) root@xxx:/# conda --version -conda 22.11.1 +conda 23.5.2 -(base) root@xxx:/# conda activate nndlbook +(base) root@xxx:/# conda list | grep numpy +numpy 1.24.3 py311h08b1b3b_1 +numpy-base 1.24.3 py311hf175353_1 +numpydoc 1.5.0 py311h06a4308_0 -(nndlbook) root@xxx:/# conda list -# packages in environment at /opt/conda/envs/nndlbook: -# -# Name Version Build Channel +(base) root@xxx:/# python --version +Python 3.11.3 -(nndlbook) root@xxx:/# python --version -Python 3.10.8 - -(nndlbook) root@x:/# conda install numpy -Collecting package metadata (current_repodata.json): done -... -Proceed ([y]/n)? y -... -Executing transaction: done - -(nndlbook) root@xxx:/# conda list -< Should see list of packages including numpy and numpy-base > - -(nndlbook) root@xxx:/# python --version -Python 3.10.8 -< No change; sometimes we get a later Python version after installing Numpy > - -(nndlbook) root@xxx:/# exit +(base) root@xxx:/# exit exit ~/DeepLearningPython35 $ docker container ls --all -< Should see a container named "deeplearning" > CONTAINER ID IMAGE COMMAND CREATED ... NAMES -xxxxxxxxxxxx continuumio/miniconda3 "/bin/bash" xxx deeplearning +xxxxxxxxxxxx xxxxxxxxxxxx "/bin/bash" xxx deeplearning ``` ### How to run the demo Python code in the created Docker container @@ -201,37 +170,40 @@ If not, do `git checkout chap1_30-hidden-neurons-3.0-eta` to switch to that bran The commands shown in the text area below do the following; the text area also shows the _Terminal_ console response to the commands: - First, just verify we see the newly created container named _deeplearning_ -- At _DeepLearningPython35_ directory, start `docker` container _deeplearning_ and specify option to attach an interactive shell, +- At _DeepLearningPython35_ directory, start `docker` container _deeplearning_ and specify option to attach an interactive shell, with `docker container start -ai deeplearning` - - At the interactive shell command line inside the container, we `cd` into the _deeplearn_ directory mounted into the container; - when we created the container, we had bind that mount to the local _DeepLearningPython35_ directory, - which must be already on the git branch _chap1_30-hidden-neurons-3.0-eta_ - - And verify what conda environments we have, with `conda info --env` - - Then we activate our own previously created conda environment _nndlbook_, with `conda activate nndlbook` - - We check the python version, with `python --version` - - Finally, we now run the demo code in _test.py_, with `python3.xxx test.py`; use control-c to break out of the run if desired + - At the interactive shell command line inside the container, we can use `ls` to see the directories at the root directory; + then `cd` into the _deeplearn_ directory mounted into the container; + - When we created the container, we had bind that mount to the local _DeepLearningPython35_ directory, + which must be already on the git branch _chap1_30-hidden-neurons-3.0-eta_ + - We can see the files in our local _DeepLearningPython35_ directory, including _test.py_, with `ls` + - We can check the python version, with `python --version` + - Now, we can run the demo code in _test.py_, with `python3.xx test.py` + - Use control-c to break out of the run if desired - After the run, we exit the container, with `exit` - Now we should be back at the Terminal console, in the _DeepLearningPython35_ directory ``` ~/DeepLearningPython35 $ ~/DeepLearningPython35 $ docker container ls --all -< Should see a container named "deeplearning" > CONTAINER ID IMAGE COMMAND CREATED ... NAMES -xxxxxxxxxxxx continuumio/miniconda3 "/bin/bash" xxx deeplearning +xxxxxxxxxxxx xxxxxxxxxxxx "/bin/bash" xxx deeplearning ~/DeepLearningPython35 $ docker container start -ai deeplearning +(base) root@xxx:/# +(base) root@xxx:/# ls +bin boot deeplearn dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var (base) root@xxx:/# cd deeplearn/ -(base) root@xxx:/deeplearn# conda info --env -< Should see two environments: base and nndlbook > - -(base) root@xxx:/deeplearn# conda activate nndlbook +(base) root@xxx:/deeplearn# +(base) root@xxx:/deeplearn# ls +MyNetwork __pycache__ mnist.pkl.gz mnist_expanded.pkl.gz mnist_svm.py network2.py test.py +README.md expand_mnist.py mnist_average_darkness.py mnist_loader.py network.py network3.py -(nndlbook) root@xxx:/deeplearn# python --version -Python 3.10.8 +(base) root@xxx:/deeplearn# python --version +Python 3.11.3 -(nndlbook) root@xxx:/deeplearn# python3.10 test.py +(base) root@xxx:/deeplearn# python3.11 test.py Epoch 0 : 8943 / 10000 Epoch 1 : 9166 / 10000 Epoch 2 : 9267 / 10000 @@ -240,10 +212,11 @@ Epoch 4 : 9337 / 10000 Epoch 5 : 9374 / 10000 Epoch 6 : 9386 / 10000 ... -< On my late-2013 MacBook Pro, it takes about a minute to do Epoch 1 to Epoch 6; use control-c to break if desired > -< Each epoch run uses the training images; then neural network is evaluated on test images > +< On my late-2013 MacBook Pro, it takes about 10s to complete first Epoch 0, so about a minute to finish Epoch 5 > +< use control-c to break if desired > +< Each epoch run uses the training images; then neural network is evaluated on the 10000 test images > -(nndlbook) root@xxx:/deeplearn# exit +(base) root@xxx:/deeplearn# exit exit ~/DeepLearningPython35 $ ``` From b8be9ba27acd35b19046003a03352d0534c0a76c Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Wed, 11 Oct 2023 23:59:23 -0400 Subject: [PATCH 17/27] Update, improve README; reflect pulling docker image continuumio/anaconda3:2023.09-0 --- README.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 26090fd..03ef803 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ## Running IEEE Boston Section class demo code -## Introduction to Practical Neural Networks and Deep Learning (Part 1)
March 18, 2023 +## Introduction to Neural Networks and Deep Learning (Part 1)
October 21, 2023 Instructions are given below for each of the five steps: * download Git software * download Docker software @@ -25,7 +25,7 @@ Unless you have a preference, you should probably just pick the first method for (For Mac: Git for Mac Installer > pick latest link (currently `git-2.33.0-intel-universal-mavericks.dmg`); This version is more than a year old but for our purposes is perfectly ok. -If you want the latest version, go to [Git - Download for macOS](https://git-scm.com/download/mac) and follow instructions for your option, e.g. Homebrew or MacPorts. +If you want the latest version, go to [Git - Download for macOS](https://git-scm.com/download/mac) and follow instructions for your preference, e.g. Homebrew or MacPorts. If you're installing from a downloaded .dmg file, you may be blocked from opening the installation package; if you see something like "macOS cannot verify that this app is free from malware", go to _System Preferences_ > _Security & Privacy_ > _General_ tab, click the lock icon in lower corner to Unlock, then under `Allow apps downloaded from` | `App Store and identified developers` > `Allow` that downloaded git-xxx.pkg file, if you're sure it is safe. @@ -48,7 +48,7 @@ this downloads the demo source code from that specified repository into your loc - `cd DeepLearningPython35` into the repository directory; this changes your directory to the directory of the downloaded demo Python source code - Verify with `git branch` that you are on the _master_ branch of the repository; the branch you are on is marked with an asterisk (*); a repository can have many versions of the source code, each stored in its own branch -- Checkout the desired branch instead of master branch, with `git checkout chap1_30-hidden-neurons-3.0-eta`; +- Checkout the desired branch instead of _master_ branch, with `git checkout chap1_30-hidden-neurons-3.0-eta`; that specific branch has the desired setup of demo code you want to run for this Part 1 class - Verify with `git branch` again that you are on the desired branch _chap1_30-hidden-neurons-3.0-eta_ which is now marked with an asterisk (*) - Use `ls -l` to see the files in the directory @@ -93,7 +93,7 @@ in the chap1 branch, at command line run `git diff ea229ac 6ba2425` to see the small changes committed in the branch (red is for text deleted, green is for text added; hit space bar once to scroll down one page; -when we see `(END)` of document, enter q to quit and get back to the command line). +when you see `(END)` of document, enter _q_ to quit and get back to the command line prompt). Acknowledgement: The repository is forked from the _DeepLearningPython35_ repository of _Michal Daniel Dobrzanski_ who ported the book's code from Python 2.7 to Python 3.5 and wrote the "orchestrator" testing file _test.py_. @@ -132,13 +132,13 @@ docker.io/continuumio/anaconda3:latest ~/DeepLearningPython35 $ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE -continuumio/anaconda3 latest xxxxxxxxxxxx n months ago n.nnGB +continuumio/anaconda3 latest xxxxxxxxxxxx nn days ago n.nnGB ~/DeepLearningPython35 $ docker run -it --name deeplearning --mount type=bind,source="$(pwd)",target=/deeplearn continuumio/anaconda3 (base) root@xxx:/# (base) root@xxx:/# conda --version -conda 23.5.2 +conda 23.7.4 (base) root@xxx:/# conda list | grep numpy numpy 1.24.3 py311h08b1b3b_1 @@ -146,14 +146,14 @@ numpy-base 1.24.3 py311hf175353_1 numpydoc 1.5.0 py311h06a4308_0 (base) root@xxx:/# python --version -Python 3.11.3 +Python 3.11.5 (base) root@xxx:/# exit exit ~/DeepLearningPython35 $ docker container ls --all CONTAINER ID IMAGE COMMAND CREATED ... NAMES -xxxxxxxxxxxx xxxxxxxxxxxx "/bin/bash" xxx deeplearning +xxxxxxxxxxxx continuumio/anaconda3 "/bin/bash" xxx deeplearning ``` ### How to run the demo Python code in the created Docker container @@ -178,15 +178,17 @@ The commands shown in the text area below do the following; the text area also s which must be already on the git branch _chap1_30-hidden-neurons-3.0-eta_ - We can see the files in our local _DeepLearningPython35_ directory, including _test.py_, with `ls` - We can check the python version, with `python --version` - - Now, we can run the demo code in _test.py_, with `python3.xx test.py` - - Use control-c to break out of the run if desired + - Now, we can run the demo code in _test.py_, with `python3.11 test.py` + - On my late-2013 MacBook Pro, it takes about 20s to complete first Epoch 0, so about a minute to finish Epoch 2 + - Each epoch run uses the training images; then neural network is evaluated on the 10000 test images + - Use control-c to break out of the run as desired - After the run, we exit the container, with `exit` - Now we should be back at the Terminal console, in the _DeepLearningPython35_ directory ``` ~/DeepLearningPython35 $ ~/DeepLearningPython35 $ docker container ls --all CONTAINER ID IMAGE COMMAND CREATED ... NAMES -xxxxxxxxxxxx xxxxxxxxxxxx "/bin/bash" xxx deeplearning +xxxxxxxxxxxx continuumio/anaconda3 "/bin/bash" xxx deeplearning ~/DeepLearningPython35 $ docker container start -ai deeplearning @@ -201,7 +203,7 @@ MyNetwork __pycache__ mnist.pkl.gz mnist_expanded.pkl.gz mnist_svm. README.md expand_mnist.py mnist_average_darkness.py mnist_loader.py network.py network3.py (base) root@xxx:/deeplearn# python --version -Python 3.11.3 +Python 3.11.5 (base) root@xxx:/deeplearn# python3.11 test.py Epoch 0 : 8943 / 10000 @@ -212,15 +214,13 @@ Epoch 4 : 9337 / 10000 Epoch 5 : 9374 / 10000 Epoch 6 : 9386 / 10000 ... -< On my late-2013 MacBook Pro, it takes about 10s to complete first Epoch 0, so about a minute to finish Epoch 5 > -< use control-c to break if desired > -< Each epoch run uses the training images; then neural network is evaluated on the 10000 test images > +< Use control-c to break out of the run as desired > (base) root@xxx:/deeplearn# exit exit ~/DeepLearningPython35 $ ``` -## End of Running IEEE Boston Section class demo code: Introduction to Practical Neural Networks and Deep Learning (Part 1) +## End of Running IEEE Boston Section class demo code: Introduction to Neural Networks and Deep Learning (Part 1) ___ ## Overview From c305145a57701562c25838191ef9b922b3250ee2 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Thu, 12 Oct 2023 01:37:39 -0400 Subject: [PATCH 18/27] Update README with workaround for current 'Docker does not recover from resource saver mode' issue --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 03ef803..e67ca1b 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,14 @@ Estimated time: 15 mins. Go to [Get Docker](https://docs.docker.com/get-docker/), and pick Docker Desktop for \[Mac | Windows | Linux\] to do the appropriate install. After installing Docker Desktop, find the application icon to run the _Docker_ app (_Docker Desktop_), so as to start _Docker Engine_; it could take about half a minute for _Docker Desktop_ window to start and open; then you could minimize or close that window (double check that _Docker Desktop_ -is still running). +is still running). +#####Public Service Announcement +Looks like currently Docker Desktop 4.24.0 (122432) for Mac has an issue being tracked here +[Docker does not recover from resource saver mode](https://github.com/docker/for-mac/issues/6933). +The workaround for me is: As soon as Docker Desktop starts, open Settings (wheel icon on top right) > left menu > Resources | Advanced +>scroll down to Resource Saver > unset Enable Resource Saver > Apply & restart button +>scroll up to Resource Allocation | CPU limit > instead of default 8, reduce to number of cores on your Mac (4 on mine) > Apply & restart button +>click Cancel button to exit Settings ### How to clone GitHub repository into local directory Estimated time: 10 mins. From e886e9ce3ea0a3ac6829c68a51cc3fbccaec84eb Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Thu, 12 Oct 2023 01:41:41 -0400 Subject: [PATCH 19/27] Fix markdown in README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e67ca1b..fc241e2 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,8 @@ Estimated time: 15 mins. Go to [Get Docker](https://docs.docker.com/get-docker/), and pick Docker Desktop for \[Mac | Windows | Linux\] to do the appropriate install. After installing Docker Desktop, find the application icon to run the _Docker_ app (_Docker Desktop_), so as to start _Docker Engine_; it could take about half a minute for _Docker Desktop_ window to start and open; then you could minimize or close that window (double check that _Docker Desktop_ -is still running). +is still running). + #####Public Service Announcement Looks like currently Docker Desktop 4.24.0 (122432) for Mac has an issue being tracked here [Docker does not recover from resource saver mode](https://github.com/docker/for-mac/issues/6933). From f8f79cab98c8293c2fca773c564ec41c85a60162 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Thu, 12 Oct 2023 01:43:42 -0400 Subject: [PATCH 20/27] More fix markdown in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fc241e2..89e0ffd 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ After installing Docker Desktop, find the application icon to run the _Docker_ a it could take about half a minute for _Docker Desktop_ window to start and open; then you could minimize or close that window (double check that _Docker Desktop_ is still running). -#####Public Service Announcement +##### Public Service Announcement Looks like currently Docker Desktop 4.24.0 (122432) for Mac has an issue being tracked here [Docker does not recover from resource saver mode](https://github.com/docker/for-mac/issues/6933). The workaround for me is: As soon as Docker Desktop starts, open Settings (wheel icon on top right) > left menu > Resources | Advanced From bdaa054d817592c9faf8de18a83e57190ecc5b24 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Thu, 12 Oct 2023 01:55:29 -0400 Subject: [PATCH 21/27] Update time for epoch run in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 89e0ffd..3e831ec 100644 --- a/README.md +++ b/README.md @@ -187,7 +187,7 @@ The commands shown in the text area below do the following; the text area also s - We can see the files in our local _DeepLearningPython35_ directory, including _test.py_, with `ls` - We can check the python version, with `python --version` - Now, we can run the demo code in _test.py_, with `python3.11 test.py` - - On my late-2013 MacBook Pro, it takes about 20s to complete first Epoch 0, so about a minute to finish Epoch 2 + - On my late-2013 MacBook Pro, it takes about 10s - 15s to complete first Epoch 0, about a minute to finish Epoch 5 - Each epoch run uses the training images; then neural network is evaluated on the 10000 test images - Use control-c to break out of the run as desired - After the run, we exit the container, with `exit` From b2a91118fb7886ae5ff9f39f592e982295e663d3 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Mon, 4 Mar 2024 01:13:49 -0500 Subject: [PATCH 22/27] Update README for March 2024 class: update instructions to install Git and Docker; go back to pulling miniconda3 image, create new env to install numpy and theano and python3.6 (latest to support theano) --- README.md | 183 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 133 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 3e831ec..375940a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ## Running IEEE Boston Section class demo code -## Introduction to Neural Networks and Deep Learning (Part 1)
October 21, 2023 +## Introduction to Neural Networks and Deep Learning (Part 1)
March 16, 2024 Instructions are given below for each of the five steps: * download Git software * download Docker software @@ -19,17 +19,13 @@ Personal and small business use is still free, though a sign-up for a Docker acc Git is a very popular source code management tool for version control, widely used among software professionals. Estimated time: 15 mins. -Go to [Install Git](https://www.atlassian.com/git/tutorials/install-git), and scroll to Install Git on \[Mac OS X | Windows | Linux\] section as appropriate. -Unless you have a preference, you should probably just pick the first method for your platform. +Go to [Install Git](https://github.com/git-guides/install-git), and scroll to Install Git on \[Windows | Mac | Linux\] section as appropriate. +Suggestion: unless you have a preference, check out the link labelled `git-scm` in the Windows and Mac sections, but also see note on Mac below. (For Mac: -Git for Mac Installer > pick latest link (currently `git-2.33.0-intel-universal-mavericks.dmg`); -This version is more than a year old but for our purposes is perfectly ok. -If you want the latest version, go to [Git - Download for macOS](https://git-scm.com/download/mac) and follow instructions for your preference, e.g. Homebrew or MacPorts. -If you're installing from a downloaded .dmg file, you may be blocked from opening the installation package; if you see something like -"macOS cannot verify that this app is free from malware", go to _System Preferences_ > _Security & Privacy_ > _General_ tab, click the lock icon in lower corner to Unlock, -then under `Allow apps downloaded from` | `App Store and identified developers` > `Allow` that downloaded git-xxx.pkg file, if you're sure it is safe. -Install just Git; you should not need to install git-credential-osxkeychain helper.) +The link labelled `macOS Git Installer` seems quite old and no longer updated. +Most MacOS will already have Git installed; even though the version is likely to be old, it is probably sufficient for our purpose here. +If you want the latest version, use the link [git-scm](https://git-scm.com/download/mac) and follow instructions; we suggest using Homebrew.) ### How to download Docker software Docker is a very popular container technology. The containers run on _Docker Engine_. @@ -41,12 +37,16 @@ it could take about half a minute for _Docker Desktop_ window to start and open; is still running). ##### Public Service Announcement -Looks like currently Docker Desktop 4.24.0 (122432) for Mac has an issue being tracked here -[Docker does not recover from resource saver mode](https://github.com/docker/for-mac/issues/6933). +Looks like my installed Docker Desktop 4.24.0 (122432) for Mac has an issue tracked here +[Docker does not recover from resource saver mode](https://github.com/docker/for-mac/issues/6933); see my work-around below. +If you are using Mac and not on macOS Monterey (version 12), it seems that Docker Desktop 4.25.0 is not available, so try downloading 4.24.x and do my work-around. +Otherwise, download the latest version (currently 4.28.0) and hopefully the issue has been fixed. +I'm staying on Docker Desktop 4.24.0 since my Mac is on Big Sur (version 11); will be getting a new Mac soon :) + The workaround for me is: As soon as Docker Desktop starts, open Settings (wheel icon on top right) > left menu > Resources | Advanced ->scroll down to Resource Saver > unset Enable Resource Saver > Apply & restart button ->scroll up to Resource Allocation | CPU limit > instead of default 8, reduce to number of cores on your Mac (4 on mine) > Apply & restart button ->click Cancel button to exit Settings +>Scroll down to Resource Saver > unset Enable Resource Saver > click Apply & restart button. +>Scroll up to Resource Allocation | CPU limit > instead of default 8, reduce to number of cores on your Mac (4 on mine) > click Apply & restart button. +>Click Cancel button to exit Settings. ### How to clone GitHub repository into local directory Estimated time: 10 mins. @@ -119,49 +119,122 @@ You must be at the _DeepLearningPython35_ directory, because the `bind mount` be Estimated time: 10 mins. The commands shown in the text area below do the following; the text area also shows the _Terminal_ console response to the commands: -- First run `docker pull continuumio/anaconda3` to download the _Anaconda_ image (based on Python 3.X), which has the _conda_, a package manager as well as -an environment manager tool; Anaconda is a very popular data science platform; the download is from the Docker hub [docker-anaconda](https://hub.docker.com/r/continuumio/anaconda3) -- Then run `docker image ls` to verify the image _continuumio/anaconda3_ (with Tag _latest_) is downloaded +- First run `docker pull continuumio/miniconda3:yy.x.x-x` to download the _Miniconda_ image (based on Python 3.X), a minimal installer for Python and _conda_, a package manager as well as +an environment manager tool; it is a small version of Anaconda, which is a very popular data science platform; the download is from the Docker hub [docker-miniconda](https://hub.docker.com/r/continuumio/miniconda3) +- Then run `docker image ls` to verify the image _continuumio/miniconda3_ (with Tag _yy.x.x-x_) is downloaded - Then run the given `docker` command to create a new container layer over the downloaded image - - At the interactive shell command line inside the container, we can look for the conda version, with `conda --version` + - At the interactive shell command line inside the new container, we can look for the conda version, with `conda --version` - (May be prompted to update to a new version of conda; if so, go ahead and follow the prompts to update) - - Do a confirming check that the Python package _Numpy_ is installed, with `conda list | grep numpy` - - Should see the _numpy_ related packages - - And do a sanity check that we do have python installed, with `python --version` - - (Extra credit: we can use _conda_ to install packages, with `conda install packagename`) + - Double-check that the Python packages we want to install are not present, and that there is only the `base` environment + - Install in a new environment: Python 3.6 (latest that supports Theano), and _Numpy_ and _Theano_, with `conda create -n py36numpytheano python=3.6 numpy theano` + - Double-check we have the newly created environment named `py36numpytheano`, with `conda env list` + - Activate the newly created environment, with `conda activate py36numpytheano` + - Do a `ls` to look for the `bind mount` target directory `deeplearn` that we named when creating the new container, then do a `cd` to change into that directory + - Now do a `ls`, we should see the files in the _DeepLearningPython35_ directory + - Do a sanity check that we will be running the python version we installed in the new environment, with `python --version` - Ok, exit our newly created local container, with `exit` - Back at the Terminal console, verify that we have created a local container named _deeplearning_, with `docker container ls --all` ``` ~/DeepLearningPython35 $ -~/DeepLearningPython35 $ docker pull continuumio/anaconda3 -Using default tag: latest +~/DeepLearningPython35 $ docker pull continuumio/miniconda3:24.1.2-0 +24.1.2-0: Pulling from continuumio/miniconda3 ... -docker.io/continuumio/anaconda3:latest +docker.io/continuumio/miniconda3:24.1.2-0 +~/DeepLearningPython35 $ ~/DeepLearningPython35 $ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE -continuumio/anaconda3 latest xxxxxxxxxxxx nn days ago n.nnGB +continuumio/miniconda3 24.1.2-0 xxxxxxxxxxxx nn .... ago nnnMB -~/DeepLearningPython35 $ docker run -it --name deeplearning --mount type=bind,source="$(pwd)",target=/deeplearn continuumio/anaconda3 +~/DeepLearningPython35 $ +~/DeepLearningPython35 $ docker run -it --name deeplearning --mount type=bind,source="$(pwd)",target=/deeplearn continuumio/miniconda3:24.1.2-0 (base) root@xxx:/# (base) root@xxx:/# conda --version -conda 23.7.4 +conda 24.1.2 +(base) root@xxx:/# python --version +Python 3.11.7 +(base) root@xxx:/# (base) root@xxx:/# conda list | grep numpy -numpy 1.24.3 py311h08b1b3b_1 -numpy-base 1.24.3 py311hf175353_1 -numpydoc 1.5.0 py311h06a4308_0 +(base) root@xxx:/# conda list | grep theano +(base) root@xxx:/# conda env list +# conda environments: +# +base * /opt/conda -(base) root@xxx:/# python --version -Python 3.11.5 -(base) root@xxx:/# exit +(base) root@xxx:/# +(base) root@xxx:/# conda create -n py36numpytheano python=3.6 numpy theano +Channels: + - defaults +Platform: linux-64 +Collecting package metadata (repodata.json): done +Solving environment: done + +## Package Plan ## + + environment location: /opt/conda/envs/py36numpytheano + + added / updated specs: + - numpy + - python=3.6 + - theano + +The following packages will be downloaded: +... +... +The following NEW packages will be INSTALLED: +... +... +Proceed ([y]/n)? y + +Downloading and Extracting Packages: + +Preparing transaction: done +Verifying transaction: done +Executing transaction: done +# +# To activate this environment, use +# +# $ conda activate py36numpytheano +# +# To deactivate an active environment, use +# +# $ conda deactivate + + +(base) root@xxx:/# +(base) root@xxx:/# conda env list +# conda environments: +# +base * /opt/conda +py36numpytheano /opt/conda/envs/py36numpytheano + +(base) root@xxx:/# +(base) root@xxx:/# conda activate py36numpytheano + +(py36numpytheano) root@xxx:/# +(py36numpytheano) root@xxx:/# ls +bin boot deeplearn dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var +(py36numpytheano) root@xxx:/# +(py36numpytheano) root@xxx:/# cd deeplearn/ +(py36numpytheano) root@xxx:/deeplearn# +(py36numpytheano) root@xxx:/deeplearn# ls +MyNetwork __pycache__ mnist.pkl.gz mnist_expanded.pkl.gz mnist_svm.py network2.py test.py +README.md expand_mnist.py mnist_average_darkness.py mnist_loader.py network.py network3.py + +(py36numpytheano) root@xxx:/deeplearn# +(py36numpytheano) root@xxx:/deeplearn# python --version +Python 3.6.13 :: Anaconda, Inc. +(py36numpytheano) +(py36numpytheano) root@xxx:/deeplearn# exit exit +~/DeepLearningPython35 $ ~/DeepLearningPython35 $ docker container ls --all -CONTAINER ID IMAGE COMMAND CREATED ... NAMES -xxxxxxxxxxxx continuumio/anaconda3 "/bin/bash" xxx deeplearning +CONTAINER ID IMAGE COMMAND CREATED ... NAMES +xxxxxxxxxxxx continuumio/miniconda3:24.1.2-0 "/bin/bash" xxx deeplearning ``` ### How to run the demo Python code in the created Docker container @@ -180,13 +253,14 @@ The commands shown in the text area below do the following; the text area also s - First, just verify we see the newly created container named _deeplearning_ - At _DeepLearningPython35_ directory, start `docker` container _deeplearning_ and specify option to attach an interactive shell, with `docker container start -ai deeplearning` - - At the interactive shell command line inside the container, we can use `ls` to see the directories at the root directory; + - At the interactive shell command line inside the container, activate the environment we created, with `conda activate py36numpytheano` + - We can use `ls` to see the directories at the root directory; then `cd` into the _deeplearn_ directory mounted into the container; - When we created the container, we had bind that mount to the local _DeepLearningPython35_ directory, which must be already on the git branch _chap1_30-hidden-neurons-3.0-eta_ - We can see the files in our local _DeepLearningPython35_ directory, including _test.py_, with `ls` - - We can check the python version, with `python --version` - - Now, we can run the demo code in _test.py_, with `python3.11 test.py` + - We can double-check the python version, with `python --version` + - Now, we can run the demo code in _test.py_, with `python3.6 test.py` - On my late-2013 MacBook Pro, it takes about 10s - 15s to complete first Epoch 0, about a minute to finish Epoch 5 - Each epoch run uses the training images; then neural network is evaluated on the 10000 test images - Use control-c to break out of the run as desired @@ -195,25 +269,33 @@ The commands shown in the text area below do the following; the text area also s ``` ~/DeepLearningPython35 $ ~/DeepLearningPython35 $ docker container ls --all -CONTAINER ID IMAGE COMMAND CREATED ... NAMES -xxxxxxxxxxxx continuumio/anaconda3 "/bin/bash" xxx deeplearning +CONTAINER ID IMAGE COMMAND CREATED ... NAMES +xxxxxxxxxxxx continuumio/miniconda3:24.1.2-0 "/bin/bash" xxx deeplearning +~/DeepLearningPython35 $ ~/DeepLearningPython35 $ docker container start -ai deeplearning (base) root@xxx:/# -(base) root@xxx:/# ls +(base) root@xxx:/# conda activate py36numpytheano + +(py36numpytheano) root@xxx:/# +(py36numpytheano) root@xxx:/# ls bin boot deeplearn dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var -(base) root@xxx:/# cd deeplearn/ -(base) root@xxx:/deeplearn# -(base) root@xxx:/deeplearn# ls +(py36numpytheano) root@xxx:/# +(py36numpytheano) root@xxx:/# cd deeplearn/ + +(py36numpytheano) root@xxx:/deeplearn# +(py36numpytheano) root@xxx:/deeplearn# ls MyNetwork __pycache__ mnist.pkl.gz mnist_expanded.pkl.gz mnist_svm.py network2.py test.py README.md expand_mnist.py mnist_average_darkness.py mnist_loader.py network.py network3.py -(base) root@xxx:/deeplearn# python --version -Python 3.11.5 +(py36numpytheano) root@xxx:/deeplearn# +(py36numpytheano) root@xxx:/deeplearn# python --version +Python 3.6.13 :: Anaconda, Inc. -(base) root@xxx:/deeplearn# python3.11 test.py +(py36numpytheano) root@xxx:/deeplearn# +(py36numpytheano) root@xxx:/deeplearn# python3.6 test.py Epoch 0 : 8943 / 10000 Epoch 1 : 9166 / 10000 Epoch 2 : 9267 / 10000 @@ -224,7 +306,8 @@ Epoch 6 : 9386 / 10000 ... < Use control-c to break out of the run as desired > -(base) root@xxx:/deeplearn# exit +(py36numpytheano) root@xxx:/deeplearn# +(py36numpytheano) root@xxx:/deeplearn# exit exit ~/DeepLearningPython35 $ ``` From 3a286124ede80cdaea8cd2ada3142a416684c227 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Fri, 8 Mar 2024 17:56:06 -0500 Subject: [PATCH 23/27] More README update for 3/16/24 class --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 375940a..01af6ac 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Git is a very popular source code management tool for version control, widely us Estimated time: 15 mins. Go to [Install Git](https://github.com/git-guides/install-git), and scroll to Install Git on \[Windows | Mac | Linux\] section as appropriate. -Suggestion: unless you have a preference, check out the link labelled `git-scm` in the Windows and Mac sections, but also see note on Mac below. +Suggestion: unless you have a preference, look into the link labelled `git-scm` in the Windows and Mac sections, but also see note on Mac below. (For Mac: The link labelled `macOS Git Installer` seems quite old and no longer updated. @@ -37,9 +37,9 @@ it could take about half a minute for _Docker Desktop_ window to start and open; is still running). ##### Public Service Announcement -Looks like my installed Docker Desktop 4.24.0 (122432) for Mac has an issue tracked here +It looks like my installed Docker Desktop 4.24.0 (122432) for Mac has an issue tracked here [Docker does not recover from resource saver mode](https://github.com/docker/for-mac/issues/6933); see my work-around below. -If you are using Mac and not on macOS Monterey (version 12), it seems that Docker Desktop 4.25.0 is not available, so try downloading 4.24.x and do my work-around. +If you are using Mac but not on macOS Monterey (version 12) or later, it seems that Docker Desktop 4.25.0 is not available, so try downloading 4.24.x and do my work-around. Otherwise, download the latest version (currently 4.28.0) and hopefully the issue has been fixed. I'm staying on Docker Desktop 4.24.0 since my Mac is on Big Sur (version 11); will be getting a new Mac soon :) @@ -117,16 +117,16 @@ as described above in "How to clone GitHub repository into local directory". You must be at the _DeepLearningPython35_ directory, because the `bind mount` being set up into the container calls `pwd` to get name of the current directory. `cd` into the directory _DeepLearningPython35_ if not already there. -Estimated time: 10 mins. +Estimated time: 15 mins. The commands shown in the text area below do the following; the text area also shows the _Terminal_ console response to the commands: - First run `docker pull continuumio/miniconda3:yy.x.x-x` to download the _Miniconda_ image (based on Python 3.X), a minimal installer for Python and _conda_, a package manager as well as -an environment manager tool; it is a small version of Anaconda, which is a very popular data science platform; the download is from the Docker hub [docker-miniconda](https://hub.docker.com/r/continuumio/miniconda3) +an environment manager tool; Miniconda is a small version of Anaconda, which is a very popular data science platform; the download source is the Docker hub [docker-miniconda](https://hub.docker.com/r/continuumio/miniconda3) - Then run `docker image ls` to verify the image _continuumio/miniconda3_ (with Tag _yy.x.x-x_) is downloaded -- Then run the given `docker` command to create a new container layer over the downloaded image +- Now run the given `docker` command to create a new container layer over the downloaded image - At the interactive shell command line inside the new container, we can look for the conda version, with `conda --version` - (May be prompted to update to a new version of conda; if so, go ahead and follow the prompts to update) - - Double-check that the Python packages we want to install are not present, and that there is only the `base` environment - - Install in a new environment: Python 3.6 (latest that supports Theano), and _Numpy_ and _Theano_, with `conda create -n py36numpytheano python=3.6 numpy theano` + - Double-check that the Python packages we want to install are not present, and that there is only the `base` (python virtual) environment + - Create and install in a new environment: Python 3.6 (latest that supports Theano), and _Numpy_ and _Theano_, with `conda create -n py36numpytheano python=3.6 numpy theano` - Double-check we have the newly created environment named `py36numpytheano`, with `conda env list` - Activate the newly created environment, with `conda activate py36numpytheano` - Do a `ls` to look for the `bind mount` target directory `deeplearn` that we named when creating the new container, then do a `cd` to change into that directory From 06409e508ca41fb5c7ee4f051277a0ac6e167331 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Fri, 8 Mar 2024 18:31:10 -0500 Subject: [PATCH 24/27] update README to remove extraneous git branches shown in terminal output --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 01af6ac..c8f339a 100644 --- a/README.md +++ b/README.md @@ -68,16 +68,12 @@ that specific branch has the desired setup of demo code you want to run for this ~/DeepLearningPython35 $ git branch chap1_30-hidden-neurons-3.0-eta - chap2_fully-matrix-based-backpropagation-mini-batch - chap6 * master ~/DeepLearningPython35 $ git checkout chap1_30-hidden-neurons-3.0-eta ~/DeepLearningPython35 $ git branch * chap1_30-hidden-neurons-3.0-eta - chap2_fully-matrix-based-backpropagation-mini-batch - chap6 master ~/DeepLearningPython35 $ ls -l From 6ab4e95a25abfadd1786060a395cc9c87ff35395 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Sun, 15 Sep 2024 19:52:52 -0400 Subject: [PATCH 25/27] Update README for Oct 26, 2024, class. Don't use the 'macOS Git Installer' link. Update version of Docker that fixes resource saver issue. Update version of miniconda3 tagged version to download. Minor edits. --- README.md | 57 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index c939ed6..93c074e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ## Running IEEE Boston Section class demo code -## Introduction to Neural Networks and Deep Learning (Part 1)
March 16, 2024 +## Introduction to Neural Networks and Deep Learning (Part 1)
October 26, 2024 Instructions are given below for each of the five steps: * download Git software * download Docker software @@ -23,7 +23,7 @@ Go to [Install Git](https://github.com/git-guides/install-git), and scroll to In Suggestion: unless you have a preference, look into the link labelled `git-scm` in the Windows and Mac sections, but also see note on Mac below. (For Mac: -The link labelled `macOS Git Installer` seems quite old and no longer updated. +Do NOT click on link `macOS Git Installer` because it is labeled "abandoned" so is NOT recommended. Most MacOS will already have Git installed; even though the version is likely to be old, it is probably sufficient for our purpose here. If you want the latest version, use the link [git-scm](https://git-scm.com/download/mac) and follow instructions; we suggest using Homebrew.) @@ -37,11 +37,12 @@ it could take about half a minute for _Docker Desktop_ window to start and open; is still running). ##### Public Service Announcement -It looks like my installed Docker Desktop 4.24.0 (122432) for Mac has an issue tracked here +It looks like my installed Docker Desktop 4.24.2 (124339) for Mac has an issue tracked here [Docker does not recover from resource saver mode](https://github.com/docker/for-mac/issues/6933); see my work-around below. -If you are using Mac but not on macOS Monterey (version 12) or later, it seems that Docker Desktop 4.25.0 is not available, so try downloading 4.24.x and do my work-around. -Otherwise, download the latest version (currently 4.28.0) and hopefully the issue has been fixed. -I'm staying on Docker Desktop 4.24.0 since my Mac is on Big Sur (version 11); will be getting a new Mac soon :) +If you are using Mac but not on macOS Monterey (version 12) or later, it seems that Docker Desktop 4.25.0+ is not available, +so try downloading latest 4.24.x and do my work-around. +Otherwise, download at least version 4.34.2 which reportedly fixes the issue. +I'm staying on Docker Desktop 4.24.2 since my Mac is on Big Sur (version 11); will be getting a new Mac soon :) The workaround for me is: As soon as Docker Desktop starts, open Settings (wheel icon on top right) > left menu > Resources | Advanced >Scroll down to Resource Saver > unset Enable Resource Saver > click Apply & restart button. @@ -50,14 +51,14 @@ The workaround for me is: As soon as Docker Desktop starts, open Settings (wheel ### How to clone GitHub repository into local directory Estimated time: 10 mins. -The commands shown in the text area below do the following; the text area also shows the _Terminal_ console response to the commands: -- Clone with `git clone https://github.com/...` the specified _GitHub_ repository at a Terminal command line; -this downloads the demo source code from that specified repository into your local computer +The commands shown in the text area below do the following listed items; the text area also shows the _Terminal_ console response to the commands: +- At a Terminal command line, clone with `git clone https://github.com/` the specified _GitHub_ repository; +this downloads the demo source code from my repository into your local computer - `cd DeepLearningPython35` into the repository directory; this changes your directory to the directory of the downloaded demo Python source code - Verify with `git branch` that you are on the _master_ branch of the repository; the branch you are on is marked with an asterisk (*); a repository can have many versions of the source code, each stored in its own branch -- Checkout the desired branch instead of _master_ branch, with `git checkout chap1_30-hidden-neurons-3.0-eta`; -that specific branch has the desired setup of demo code you want to run for this Part 1 class +- Checkout the desired branch instead of _master_ branch, with `git checkout `; that specific branch has the desired setup of demo code you want to run. + - For the Part 1 class: `git checkout chap1_30-hidden-neurons-3.0-eta` - Verify with `git branch` again that you are on the desired branch _chap1_30-hidden-neurons-3.0-eta_ which is now marked with an asterisk (*) - Use `ls -l` to see the files in the directory ``` @@ -114,11 +115,11 @@ You must be at the _DeepLearningPython35_ directory, because the `bind mount` be `cd` into the directory _DeepLearningPython35_ if not already there. Estimated time: 15 mins. -The commands shown in the text area below do the following; the text area also shows the _Terminal_ console response to the commands: -- First run `docker pull continuumio/miniconda3:yy.x.x-x` to download the _Miniconda_ image (based on Python 3.X), a minimal installer for Python and _conda_, a package manager as well as -an environment manager tool; Miniconda is a small version of Anaconda, which is a very popular data science platform; the download source is the Docker hub [docker-miniconda](https://hub.docker.com/r/continuumio/miniconda3) +The commands shown in the text area below do the following listed items; the text area also shows the _Terminal_ console response to the commands: +- First run `docker pull continuumio/miniconda3:yy.x.x-x` to download the tagged _miniconda3_ image (based on Python 3.X), a minimal installer for Python and _conda_, a package manager as well as +an environment manager tool; Miniconda is a small version of Anaconda, which is a very popular data science platform; the download source is the Docker hub [docker-miniconda > Tags](https://hub.docker.com/r/continuumio/miniconda3/tags) - Then run `docker image ls` to verify the image _continuumio/miniconda3_ (with Tag _yy.x.x-x_) is downloaded -- Now run the given `docker` command to create a new container layer over the downloaded image +- Now run the below given `docker` command to create a new container layer over the downloaded image - At the interactive shell command line inside the new container, we can look for the conda version, with `conda --version` - (May be prompted to update to a new version of conda; if so, go ahead and follow the prompts to update) - Double-check that the Python packages we want to install are not present, and that there is only the `base` (python virtual) environment @@ -132,24 +133,24 @@ an environment manager tool; Miniconda is a small version of Anaconda, which is - Back at the Terminal console, verify that we have created a local container named _deeplearning_, with `docker container ls --all` ``` ~/DeepLearningPython35 $ -~/DeepLearningPython35 $ docker pull continuumio/miniconda3:24.1.2-0 -24.1.2-0: Pulling from continuumio/miniconda3 +~/DeepLearningPython35 $ docker pull continuumio/miniconda3:24.7.1-0 +24.7.1-0: Pulling from continuumio/miniconda3 ... -docker.io/continuumio/miniconda3:24.1.2-0 +docker.io/continuumio/miniconda3:24.7.1-0 ~/DeepLearningPython35 $ ~/DeepLearningPython35 $ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE -continuumio/miniconda3 24.1.2-0 xxxxxxxxxxxx nn .... ago nnnMB +continuumio/miniconda3 24.7.1-0 xxxxxxxxxxxx nn .... ago nnnMB ~/DeepLearningPython35 $ -~/DeepLearningPython35 $ docker run -it --name deeplearning --mount type=bind,source="$(pwd)",target=/deeplearn continuumio/miniconda3:24.1.2-0 +~/DeepLearningPython35 $ docker run -it --name deeplearning --mount type=bind,source="$(pwd)",target=/deeplearn continuumio/miniconda3:24.7.1-0 (base) root@xxx:/# (base) root@xxx:/# conda --version -conda 24.1.2 +conda 24.7.1 (base) root@xxx:/# python --version -Python 3.11.7 +Python 3.12.4 (base) root@xxx:/# (base) root@xxx:/# conda list | grep numpy @@ -230,7 +231,7 @@ exit ~/DeepLearningPython35 $ ~/DeepLearningPython35 $ docker container ls --all CONTAINER ID IMAGE COMMAND CREATED ... NAMES -xxxxxxxxxxxx continuumio/miniconda3:24.1.2-0 "/bin/bash" xxx deeplearning +xxxxxxxxxxxx continuumio/miniconda3:24.7.1-0 "/bin/bash" xxx deeplearning ``` ### How to run the demo Python code in the created Docker container @@ -241,11 +242,13 @@ in "How to clone GitHub repository into local directory". `cd` into the directory _DeepLearningPython35_ if not already there. -You must be on the branch _chap1_30-hidden-neurons-3.0-eta_. +You must be on the specified branch for the class +- For the Part 1 class: _chap1_30-hidden-neurons-3.0-eta_ + Verify with `git branch` (see section on "How to clone GitHub repository into local directory"). -If not, do `git checkout chap1_30-hidden-neurons-3.0-eta` to switch to that branch, then verify with `git branch`. +If not, do e.g. for Part 1 class `git checkout chap1_30-hidden-neurons-3.0-eta` to switch to that branch, then verify with `git branch`. -The commands shown in the text area below do the following; the text area also shows the _Terminal_ console response to the commands: +The commands shown in the text area below do the following listed items; the text area also shows the _Terminal_ console response to the commands: - First, just verify we see the newly created container named _deeplearning_ - At _DeepLearningPython35_ directory, start `docker` container _deeplearning_ and specify option to attach an interactive shell, with `docker container start -ai deeplearning` @@ -266,7 +269,7 @@ The commands shown in the text area below do the following; the text area also s ~/DeepLearningPython35 $ ~/DeepLearningPython35 $ docker container ls --all CONTAINER ID IMAGE COMMAND CREATED ... NAMES -xxxxxxxxxxxx continuumio/miniconda3:24.1.2-0 "/bin/bash" xxx deeplearning +xxxxxxxxxxxx continuumio/miniconda3:24.7.1-0 "/bin/bash" xxx deeplearning ~/DeepLearningPython35 $ ~/DeepLearningPython35 $ docker container start -ai deeplearning From a0f4c3bd4e69410287a3abfadfbe169181a476f1 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Sun, 2 Mar 2025 17:24:30 -0500 Subject: [PATCH 26/27] Update README for Mar 22 2025 class. Update status of the Docker resource saver issue which reportedly resurfaced in Jan 2025. Update Docker container creation to install Theano maintenance version, and the compatible Python 3.9 and Numpy versions. --- README.md | 160 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 82 insertions(+), 78 deletions(-) diff --git a/README.md b/README.md index 93c074e..37621b1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ## Running IEEE Boston Section class demo code -## Introduction to Neural Networks and Deep Learning (Part 1)
October 26, 2024 +## Introduction to Neural Networks and Deep Learning (Part 1)
March 22, 2025 Instructions are given below for each of the five steps: * download Git software * download Docker software @@ -13,7 +13,7 @@ we decided to create a _Docker_ container and to run the demo code in it. In software engineering parlance, a _container_ packages up code and all its dependencies into a standard unit of software so that the application can run anywhere, as long as the container engine supports the underlying operating system. Docker is sufficiently popular nowadays so that installing as well as running Docker on different platforms should be well supported and documented. -Personal and small business use is still free, though a sign-up for a Docker account may be required. +Personal and most small business use is still free, though a sign-up for a Docker account may be required. ### How to download Git software Git is a very popular source code management tool for version control, widely used among software professionals. @@ -23,7 +23,7 @@ Go to [Install Git](https://github.com/git-guides/install-git), and scroll to In Suggestion: unless you have a preference, look into the link labelled `git-scm` in the Windows and Mac sections, but also see note on Mac below. (For Mac: -Do NOT click on link `macOS Git Installer` because it is labeled "abandoned" so is NOT recommended. +Do NOT click on link `macOS Git Installer` because it is labeled _abandoned_ so is NOT recommended. Most MacOS will already have Git installed; even though the version is likely to be old, it is probably sufficient for our purpose here. If you want the latest version, use the link [git-scm](https://git-scm.com/download/mac) and follow instructions; we suggest using Homebrew.) @@ -40,8 +40,9 @@ is still running). It looks like my installed Docker Desktop 4.24.2 (124339) for Mac has an issue tracked here [Docker does not recover from resource saver mode](https://github.com/docker/for-mac/issues/6933); see my work-around below. If you are using Mac but not on macOS Monterey (version 12) or later, it seems that Docker Desktop 4.25.0+ is not available, -so try downloading latest 4.24.x and do my work-around. -Otherwise, download at least version 4.34.2 which reportedly fixes the issue. +so try downloading latest 4.24.x (sorry, you'd need to [google around](https://forums.docker.com/t/where-can-i-download-an-older-version-of-docker-desktop-for-mac/139977/4) +because the direct downloads don't seem available anymore) and do my work-around below. +Otherwise, download at least version 4.38.0, because the issue linked above had a report dated Jan 10, 2025, of seeing the problem in version 4.37.2. I'm staying on Docker Desktop 4.24.2 since my Mac is on Big Sur (version 11); will be getting a new Mac soon :) The workaround for me is: As soon as Docker Desktop starts, open Settings (wheel icon on top right) > left menu > Resources | Advanced @@ -51,13 +52,13 @@ The workaround for me is: As soon as Docker Desktop starts, open Settings (wheel ### How to clone GitHub repository into local directory Estimated time: 10 mins. -The commands shown in the text area below do the following listed items; the text area also shows the _Terminal_ console response to the commands: +The commands shown in the text-block area below do the following listed items; the text-block area also shows the _Terminal_ console response to the commands: - At a Terminal command line, clone with `git clone https://github.com/` the specified _GitHub_ repository; this downloads the demo source code from my repository into your local computer - `cd DeepLearningPython35` into the repository directory; this changes your directory to the directory of the downloaded demo Python source code - Verify with `git branch` that you are on the _master_ branch of the repository; the branch you are on is marked with an asterisk (*); a repository can have many versions of the source code, each stored in its own branch -- Checkout the desired branch instead of _master_ branch, with `git checkout `; that specific branch has the desired setup of demo code you want to run. +- Checkout the desired branch instead of _master_ branch, with `git checkout `; that specific branch has the desired setup of demo code you want to run - For the Part 1 class: `git checkout chap1_30-hidden-neurons-3.0-eta` - Verify with `git branch` again that you are on the desired branch _chap1_30-hidden-neurons-3.0-eta_ which is now marked with an asterisk (*) - Use `ls -l` to see the files in the directory @@ -93,12 +94,12 @@ total 158088 (Skip until class) To run the desired setup of demo code, "uncomment in" or "comment out" as appropriate the code in _test.py_ in order to specify the neural network and deep learning configuration to run. -(Skip until class) To see an example of the (flexible but somewhat hackish and minimalist) changes I made in _test.py_ in order to run the demo -in the chap1 branch, at command line run +(Skip until class) To see an example of the flexible but somewhat hackish and minimalist changes I made in _test.py_ in order to run the desired demo: +(Note: red is for text deleted, green is for text added; hit space bar once to scroll down one page; +when you see `(END)` of document, enter _q_ to quit and get back to the command line prompt.) +- For the Part 1 class: in the _chap1_30-hidden-neurons-3.0-eta_ branch, at command line run `git diff ea229ac 6ba2425` -to see the small changes committed in the branch -(red is for text deleted, green is for text added; hit space bar once to scroll down one page; -when you see `(END)` of document, enter _q_ to quit and get back to the command line prompt). +to see the small changes to the _test.py_ file in that branch Acknowledgement: The repository is forked from the _DeepLearningPython35_ repository of _Michal Daniel Dobrzanski_ who ported the book's code from Python 2.7 to Python 3.5 and wrote the "orchestrator" testing file _test.py_. @@ -115,7 +116,7 @@ You must be at the _DeepLearningPython35_ directory, because the `bind mount` be `cd` into the directory _DeepLearningPython35_ if not already there. Estimated time: 15 mins. -The commands shown in the text area below do the following listed items; the text area also shows the _Terminal_ console response to the commands: +The commands shown in the text-block area below do the following listed items; the text-block area also shows the _Terminal_ console response to the commands: - First run `docker pull continuumio/miniconda3:yy.x.x-x` to download the tagged _miniconda3_ image (based on Python 3.X), a minimal installer for Python and _conda_, a package manager as well as an environment manager tool; Miniconda is a small version of Anaconda, which is a very popular data science platform; the download source is the Docker hub [docker-miniconda > Tags](https://hub.docker.com/r/continuumio/miniconda3/tags) - Then run `docker image ls` to verify the image _continuumio/miniconda3_ (with Tag _yy.x.x-x_) is downloaded @@ -123,46 +124,48 @@ an environment manager tool; Miniconda is a small version of Anaconda, which is - At the interactive shell command line inside the new container, we can look for the conda version, with `conda --version` - (May be prompted to update to a new version of conda; if so, go ahead and follow the prompts to update) - Double-check that the Python packages we want to install are not present, and that there is only the `base` (python virtual) environment - - Create and install in a new environment: Python 3.6 (latest that supports Theano), and _Numpy_ and _Theano_, with `conda create -n py36numpytheano python=3.6 numpy theano` - - Double-check we have the newly created environment named `py36numpytheano`, with `conda env list` - - Activate the newly created environment, with `conda activate py36numpytheano` + - Create and install in a new environment: Python 3.9 (supports Theano latest maintenance version), and _Numpy_ and _Theano_, with `conda create -n py39numpy1235theano105 python=3.9 numpy=1.23.5 theano=1.0.5` + - Double-check we have the newly created environment named `py39numpy1235theano105`, with `conda env list` + - Activate the newly created environment, with `conda activate py39numpy1235theano105` - Do a `ls` to look for the `bind mount` target directory `deeplearn` that we named when creating the new container, then do a `cd` to change into that directory - Now do a `ls`, we should see the files in the _DeepLearningPython35_ directory - Do a sanity check that we will be running the python version we installed in the new environment, with `python --version` - Ok, exit our newly created local container, with `exit` -- Back at the Terminal console, verify that we have created a local container named _deeplearning_, with `docker container ls --all` +- Back at the Terminal console, verify that we have created a local container named _deeplearning_, with `docker container ls --latest` ``` ~/DeepLearningPython35 $ -~/DeepLearningPython35 $ docker pull continuumio/miniconda3:24.7.1-0 -24.7.1-0: Pulling from continuumio/miniconda3 +~/DeepLearningPython35 $ docker pull continuumio/miniconda3:25.1.1-2 +25.1.1-2: Pulling from continuumio/miniconda3 +... +... +docker.io/continuumio/miniconda3:25.1.1-2 ... -docker.io/continuumio/miniconda3:24.7.1-0 ~/DeepLearningPython35 $ ~/DeepLearningPython35 $ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE -continuumio/miniconda3 24.7.1-0 xxxxxxxxxxxx nn .... ago nnnMB +continuumio/miniconda3 25.1.1-2 xxxxxxxxxxxx nn .... ago nnnMB ~/DeepLearningPython35 $ -~/DeepLearningPython35 $ docker run -it --name deeplearning --mount type=bind,source="$(pwd)",target=/deeplearn continuumio/miniconda3:24.7.1-0 +~/DeepLearningPython35 $ docker run -it --name deeplearning --mount type=bind,source="$(pwd)",target=/deeplearn continuumio/miniconda3:25.1.1-2 (base) root@xxx:/# (base) root@xxx:/# conda --version -conda 24.7.1 +conda 25.1.1 (base) root@xxx:/# python --version -Python 3.12.4 +Python 3.12.9 (base) root@xxx:/# (base) root@xxx:/# conda list | grep numpy (base) root@xxx:/# conda list | grep theano + (base) root@xxx:/# conda env list # conda environments: # base * /opt/conda - (base) root@xxx:/# -(base) root@xxx:/# conda create -n py36numpytheano python=3.6 numpy theano +(base) root@xxx:/# conda create -n py39numpy1235theano105 python=3.9 numpy=1.23.5 theano=1.0.5 Channels: - defaults Platform: linux-64 @@ -171,12 +174,12 @@ Solving environment: done ## Package Plan ## - environment location: /opt/conda/envs/py36numpytheano + environment location: /opt/conda/envs/py39numpy1235theano105 added / updated specs: - - numpy - - python=3.6 - - theano + - numpy=1.23.5 + - python=3.9 + - theano=1.0.5 The following packages will be downloaded: ... @@ -194,7 +197,7 @@ Executing transaction: done # # To activate this environment, use # -# $ conda activate py36numpytheano +# $ conda activate py39numpy1235theano105 # # To deactivate an active environment, use # @@ -206,32 +209,32 @@ Executing transaction: done # conda environments: # base * /opt/conda -py36numpytheano /opt/conda/envs/py36numpytheano +py39numpy1235theano105 /opt/conda/envs/py39numpy1235theano105 (base) root@xxx:/# -(base) root@xxx:/# conda activate py36numpytheano +(base) root@xxx:/# conda activate py39numpy1235theano105 -(py36numpytheano) root@xxx:/# -(py36numpytheano) root@xxx:/# ls +(py39numpy1235theano105) root@xxx:/# +(py39numpy1235theano105) root@xxx:/# ls bin boot deeplearn dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var -(py36numpytheano) root@xxx:/# -(py36numpytheano) root@xxx:/# cd deeplearn/ -(py36numpytheano) root@xxx:/deeplearn# -(py36numpytheano) root@xxx:/deeplearn# ls +(py39numpy1235theano105) root@xxx:/# +(py39numpy1235theano105) root@xxx:/# cd deeplearn/ + +(py39numpy1235theano105) root@xxx:/deeplearn# +(py39numpy1235theano105) root@xxx:/deeplearn# ls MyNetwork __pycache__ mnist.pkl.gz mnist_expanded.pkl.gz mnist_svm.py network2.py test.py README.md expand_mnist.py mnist_average_darkness.py mnist_loader.py network.py network3.py -(py36numpytheano) root@xxx:/deeplearn# -(py36numpytheano) root@xxx:/deeplearn# python --version -Python 3.6.13 :: Anaconda, Inc. -(py36numpytheano) -(py36numpytheano) root@xxx:/deeplearn# exit +(py39numpy1235theano105) root@xxx:/deeplearn# python --version +Python 3.9.21 +(py39numpy1235theano105) root@xxx:/deeplearn# +(py39numpy1235theano105) root@xxx:/deeplearn# exit exit ~/DeepLearningPython35 $ -~/DeepLearningPython35 $ docker container ls --all +~/DeepLearningPython35 $ docker container ls --latest CONTAINER ID IMAGE COMMAND CREATED ... NAMES -xxxxxxxxxxxx continuumio/miniconda3:24.7.1-0 "/bin/bash" xxx deeplearning +xxxxxxxxxxxx continuumio/miniconda3:25.1.1-2 "/bin/bash" xxx deeplearning ``` ### How to run the demo Python code in the created Docker container @@ -243,70 +246,71 @@ in "How to clone GitHub repository into local directory". `cd` into the directory _DeepLearningPython35_ if not already there. You must be on the specified branch for the class -- For the Part 1 class: _chap1_30-hidden-neurons-3.0-eta_ +- For the Part 1 class: _chap1_30-hidden-neurons-3.0-eta_ branch Verify with `git branch` (see section on "How to clone GitHub repository into local directory"). -If not, do e.g. for Part 1 class `git checkout chap1_30-hidden-neurons-3.0-eta` to switch to that branch, then verify with `git branch`. +If not, do +- For the Part 1 class `git checkout chap1_30-hidden-neurons-3.0-eta` to switch to that branch, then verify with `git branch`. -The commands shown in the text area below do the following listed items; the text area also shows the _Terminal_ console response to the commands: +The commands shown in the text-block area below do the following listed items; the text-block area also shows the _Terminal_ console response to the commands: - First, just verify we see the newly created container named _deeplearning_ - At _DeepLearningPython35_ directory, start `docker` container _deeplearning_ and specify option to attach an interactive shell, with `docker container start -ai deeplearning` - - At the interactive shell command line inside the container, activate the environment we created, with `conda activate py36numpytheano` + - At the interactive shell command line inside the container, activate the environment we created, with `conda activate py39numpy1235theano105` - We can use `ls` to see the directories at the root directory; then `cd` into the _deeplearn_ directory mounted into the container; - When we created the container, we had bind that mount to the local _DeepLearningPython35_ directory, which must be already on the git branch _chap1_30-hidden-neurons-3.0-eta_ - We can see the files in our local _DeepLearningPython35_ directory, including _test.py_, with `ls` - We can double-check the python version, with `python --version` - - Now, we can run the demo code in _test.py_, with `python3.6 test.py` - - On my late-2013 MacBook Pro, it takes about 10s - 15s to complete first Epoch 0, about a minute to finish Epoch 5 + - Now, we can run the demo code in _test.py_, with `python3.9 test.py` + - On my late-2013 MacBook Pro, it takes about 10s - 15s to complete first Epoch 0, about a minute to finish Epoch 0 to Epoch 5 - Each epoch run uses the training images; then neural network is evaluated on the 10000 test images - - Use control-c to break out of the run as desired + - Use control-C to break out of the run as desired - After the run, we exit the container, with `exit` - Now we should be back at the Terminal console, in the _DeepLearningPython35_ directory ``` ~/DeepLearningPython35 $ -~/DeepLearningPython35 $ docker container ls --all +~/DeepLearningPython35 $ docker container ls --latest CONTAINER ID IMAGE COMMAND CREATED ... NAMES -xxxxxxxxxxxx continuumio/miniconda3:24.7.1-0 "/bin/bash" xxx deeplearning +xxxxxxxxxxxx continuumio/miniconda3:25.1.1-2 "/bin/bash" xxx deeplearning ~/DeepLearningPython35 $ ~/DeepLearningPython35 $ docker container start -ai deeplearning (base) root@xxx:/# -(base) root@xxx:/# conda activate py36numpytheano +(base) root@xxx:/# conda activate py39numpy1235theano105 -(py36numpytheano) root@xxx:/# -(py36numpytheano) root@xxx:/# ls +(py39numpy1235theano105) root@xxx:/# +(py39numpy1235theano105) root@xxx:/# ls bin boot deeplearn dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var -(py36numpytheano) root@xxx:/# -(py36numpytheano) root@xxx:/# cd deeplearn/ +(py39numpy1235theano105) root@xxx:/# +(py39numpy1235theano105) root@xxx:/# cd deeplearn/ -(py36numpytheano) root@xxx:/deeplearn# -(py36numpytheano) root@xxx:/deeplearn# ls +(py39numpy1235theano105) root@xxx:/deeplearn# +(py39numpy1235theano105) root@xxx:/deeplearn# ls MyNetwork __pycache__ mnist.pkl.gz mnist_expanded.pkl.gz mnist_svm.py network2.py test.py README.md expand_mnist.py mnist_average_darkness.py mnist_loader.py network.py network3.py -(py36numpytheano) root@xxx:/deeplearn# -(py36numpytheano) root@xxx:/deeplearn# python --version -Python 3.6.13 :: Anaconda, Inc. - -(py36numpytheano) root@xxx:/deeplearn# -(py36numpytheano) root@xxx:/deeplearn# python3.6 test.py -Epoch 0 : 8943 / 10000 -Epoch 1 : 9166 / 10000 -Epoch 2 : 9267 / 10000 -Epoch 3 : 9340 / 10000 -Epoch 4 : 9337 / 10000 -Epoch 5 : 9374 / 10000 -Epoch 6 : 9386 / 10000 +(py39numpy1235theano105) root@xxx:/deeplearn# +(py39numpy1235theano105) root@xxx:/deeplearn# python --version +Python 3.9.21 + +(py39numpy1235theano105) root@xxx:/deeplearn# +(py39numpy1235theano105) root@xxx:/deeplearn# python3.9 test.py +Epoch 0 : 8020 / 10000 +Epoch 1 : 8130 / 10000 +Epoch 2 : 9281 / 10000 +Epoch 3 : 9338 / 10000 +Epoch 4 : 9347 / 10000 +Epoch 5 : 9404 / 10000 +Epoch 6 : 9462 / 10000 ... -< Use control-c to break out of the run as desired > +< Use control-C to break out of the run as desired > -(py36numpytheano) root@xxx:/deeplearn# -(py36numpytheano) root@xxx:/deeplearn# exit +(py39numpy1235theano105) root@xxx:/deeplearn# +(py39numpy1235theano105) root@xxx:/deeplearn# exit exit ~/DeepLearningPython35 $ ``` From 5fea29c83253d36d1e1649aea9924422c9c9c385 Mon Sep 17 00:00:00 2001 From: Chong-Lim Kim Date: Sun, 30 Mar 2025 14:14:58 -0400 Subject: [PATCH 27/27] README update for Apr 19 2025 new Part 2 class, some edits for the Docker resource saver issue --- README.md | 78 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 37621b1..0c98828 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ## Running IEEE Boston Section class demo code -## Introduction to Neural Networks and Deep Learning (Part 1)
March 22, 2025 +## Introduction to Neural Networks and Deep Learning (Part 2, Section 1)
April 19, 2025 Instructions are given below for each of the five steps: * download Git software * download Docker software @@ -13,7 +13,7 @@ we decided to create a _Docker_ container and to run the demo code in it. In software engineering parlance, a _container_ packages up code and all its dependencies into a standard unit of software so that the application can run anywhere, as long as the container engine supports the underlying operating system. Docker is sufficiently popular nowadays so that installing as well as running Docker on different platforms should be well supported and documented. -Personal and most small business use is still free, though a sign-up for a Docker account may be required. +Personal and most small business use is still free. I have been using it here without needing to sign in into a Docker account though that could change. ### How to download Git software Git is a very popular source code management tool for version control, widely used among software professionals. @@ -39,10 +39,10 @@ is still running). ##### Public Service Announcement It looks like my installed Docker Desktop 4.24.2 (124339) for Mac has an issue tracked here [Docker does not recover from resource saver mode](https://github.com/docker/for-mac/issues/6933); see my work-around below. -If you are using Mac but not on macOS Monterey (version 12) or later, it seems that Docker Desktop 4.25.0+ is not available, -so try downloading latest 4.24.x (sorry, you'd need to [google around](https://forums.docker.com/t/where-can-i-download-an-older-version-of-docker-desktop-for-mac/139977/4) -because the direct downloads don't seem available anymore) and do my work-around below. -Otherwise, download at least version 4.38.0, because the issue linked above had a report dated Jan 10, 2025, of seeing the problem in version 4.37.2. +Try to download at least version 4.38.0, because the issue linked above had a report dated Jan 10, 2025, of seeing the problem in version 4.37.2. +If you are using Mac but not on macOS Monterey (version 12) or later, it seems that Docker Desktop 4.25.0+ does not run on the earlier Mac, +so try downloading 4.24.2 (sorry, you'd need to [google around](https://forums.docker.com/t/where-can-i-download-an-older-version-of-docker-desktop-for-mac/139977/4) +because the download/install page says Docker supports current release of macOS and the previous two releases) then do my work-around below. I'm staying on Docker Desktop 4.24.2 since my Mac is on Big Sur (version 11); will be getting a new Mac soon :) The workaround for me is: As soon as Docker Desktop starts, open Settings (wheel icon on top right) > left menu > Resources | Advanced @@ -60,7 +60,8 @@ this downloads the demo source code from my repository into your local computer a repository can have many versions of the source code, each stored in its own branch - Checkout the desired branch instead of _master_ branch, with `git checkout `; that specific branch has the desired setup of demo code you want to run - For the Part 1 class: `git checkout chap1_30-hidden-neurons-3.0-eta` -- Verify with `git branch` again that you are on the desired branch _chap1_30-hidden-neurons-3.0-eta_ which is now marked with an asterisk (*) + - For the Part 2 (Section 1) class: `git checkout chap6_2ConvPool-FullyConn-Softmax-ReLU-L2` +- Verify with `git branch` again that you are on the desired branch e.g. _chap6_2ConvPool-FullyConn-Softmax-ReLU-L2_ which is now marked with an asterisk (*) - Use `ls -l` to see the files in the directory ``` ~ $ @@ -70,25 +71,25 @@ a repository can have many versions of the source code, each stored in its own b ~/DeepLearningPython35 $ git branch chap1_30-hidden-neurons-3.0-eta + chap6_2ConvPool-FullyConn-Softmax-ReLU-L2 * master -~/DeepLearningPython35 $ git checkout chap1_30-hidden-neurons-3.0-eta +~/DeepLearningPython35 $ git checkout chap6_2ConvPool-FullyConn-Softmax-ReLU-L2 ~/DeepLearningPython35 $ git branch -* chap1_30-hidden-neurons-3.0-eta + chap1_30-hidden-neurons-3.0-eta +* chap6_2ConvPool-FullyConn-Softmax-ReLU-L2 master ~/DeepLearningPython35 $ ls -l -total 158088 +total 158392 -rw-r--r-- 1 clkim staff 492526 Feb 29 2020 MyNetwork --rw-r--r-- 1 clkim staff 14338 Mar 10 17:04 README.md +-rw-r--r-- 1 clkim staff 619 Mar 30 12:41 README.md ... ... --rw-r--r-- 1 clkim staff 770 Feb 29 2020 mnist_svm.py --rw-r--r-- 1 clkim staff 6398 Mar 11 2021 network.py -rw-r--r-- 1 clkim staff 15252 Feb 29 2020 network2.py --rw-r--r--@ 1 clkim staff 13000 Feb 29 2020 network3.py --rw-r--r-- 1 clkim staff 7394 Mar 8 23:34 test.py +-rw-r--r-- 1 clkim staff 13642 Mar 30 12:41 network3.py +-rw-r--r-- 1 clkim staff 8808 Mar 30 12:41 test.py ~/DeepLearningPython35 $ ``` (Skip until class) To run the desired setup of demo code, "uncomment in" or "comment out" as appropriate the code in _test.py_ in order to specify @@ -96,10 +97,12 @@ the neural network and deep learning configuration to run. (Skip until class) To see an example of the flexible but somewhat hackish and minimalist changes I made in _test.py_ in order to run the desired demo: (Note: red is for text deleted, green is for text added; hit space bar once to scroll down one page; -when you see `(END)` of document, enter _q_ to quit and get back to the command line prompt.) +when you see `(END)` of document, enter _q_ to quit and get back to the command line prompt.) +In the respective branch below - For the Part 1 class: in the _chap1_30-hidden-neurons-3.0-eta_ branch, at command line run `git diff ea229ac 6ba2425` -to see the small changes to the _test.py_ file in that branch +- For the Part 2 (Section 1) class: in the _chap6_2ConvPool-FullyConn-Softmax-ReLU-L2_ branch, at command line run +`git diff fe4ced0 025d21b` Acknowledgement: The repository is forked from the _DeepLearningPython35_ repository of _Michal Daniel Dobrzanski_ who ported the book's code from Python 2.7 to Python 3.5 and wrote the "orchestrator" testing file _test.py_. @@ -247,10 +250,14 @@ in "How to clone GitHub repository into local directory". You must be on the specified branch for the class - For the Part 1 class: _chap1_30-hidden-neurons-3.0-eta_ branch +- For the Part 2 (Secion 1) class: _chap6_2ConvPool-FullyConn-Softmax-ReLU-L2_ branch Verify with `git branch` (see section on "How to clone GitHub repository into local directory"). If not, do -- For the Part 1 class `git checkout chap1_30-hidden-neurons-3.0-eta` to switch to that branch, then verify with `git branch`. +- For the Part 1 class `git checkout chap1_30-hidden-neurons-3.0-eta` to switch to that branch. +- For the Part 2 (Section 1) class `git checkout chap6_2ConvPool-FullyConn-Softmax-ReLU-L2` to switch to that branch. + +Then verify with `git branch`. The commands shown in the text-block area below do the following listed items; the text-block area also shows the _Terminal_ console response to the commands: - First, just verify we see the newly created container named _deeplearning_ @@ -260,12 +267,14 @@ The commands shown in the text-block area below do the following listed items; t - We can use `ls` to see the directories at the root directory; then `cd` into the _deeplearn_ directory mounted into the container; - When we created the container, we had bind that mount to the local _DeepLearningPython35_ directory, - which must be already on the git branch _chap1_30-hidden-neurons-3.0-eta_ + which must be already on the desired git branch, either for Part 1 class _chap1_30-hidden-neurons-3.0-eta_, or for Part 2 Section 1 class _chap6_2ConvPool-FullyConn-Softmax-ReLU-L2_ - We can see the files in our local _DeepLearningPython35_ directory, including _test.py_, with `ls` - We can double-check the python version, with `python --version` - Now, we can run the demo code in _test.py_, with `python3.9 test.py` - - On my late-2013 MacBook Pro, it takes about 10s - 15s to complete first Epoch 0, about a minute to finish Epoch 0 to Epoch 5 - - Each epoch run uses the training images; then neural network is evaluated on the 10000 test images + - On my late-2013 MacBook Pro: + - Part 1 class: it takes about 10s - 15s to complete first Epoch 0, about a minute to finish six Epoch 0 to Epoch 5 + - Part 2 (Section 1) class: it takes about 30 - 35s to complete each Epoch + - Each epoch run uses the 50000 training images; then neural network is evaluated on the 10000 test images - Use control-C to break out of the run as desired - After the run, we exit the container, with `exit` - Now we should be back at the Terminal console, in the _DeepLearningPython35_ directory @@ -299,6 +308,8 @@ Python 3.9.21 (py39numpy1235theano105) root@xxx:/deeplearn# (py39numpy1235theano105) root@xxx:/deeplearn# python3.9 test.py + + Epoch 0 : 8020 / 10000 Epoch 1 : 8130 / 10000 Epoch 2 : 9281 / 10000 @@ -307,6 +318,29 @@ Epoch 4 : 9347 / 10000 Epoch 5 : 9404 / 10000 Epoch 6 : 9462 / 10000 ... + + +...... UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy (detected version 1.23.5 + warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}" +Running with a CPU. If this is not desired, then the modify network3.py to set +the GPU flag to True. +Training mini-batch number 0 +Training mini-batch number 1000 +Training mini-batch number 2000 +Training mini-batch number 3000 +Training mini-batch number 4000 +Epoch 0: validation accuracy 97.17% +This is the best validation accuracy to date. +The corresponding test accuracy is 96.65% +Training mini-batch number 5000 +Training mini-batch number 6000 +Training mini-batch number 7000 +Training mini-batch number 8000 +Training mini-batch number 9000 +Epoch 1: validation accuracy 98.10% +This is the best validation accuracy to date. +The corresponding test accuracy is 97.80% + < Use control-C to break out of the run as desired > (py39numpy1235theano105) root@xxx:/deeplearn# @@ -314,7 +348,7 @@ Epoch 6 : 9462 / 10000 exit ~/DeepLearningPython35 $ ``` -## End of Running IEEE Boston Section class demo code: Introduction to Neural Networks and Deep Learning (Part 1) +## End of Running IEEE Boston Section class demo code: Introduction to Neural Networks and Deep Learning (Part 1/Part 2) ___ ## Overview