From 2ca89b8b7eddb856fbfb71b966a784faae9b9869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Corpe=C3=B1o?= Date: Tue, 30 Aug 2022 17:24:48 -0600 Subject: [PATCH 1/5] added branch 03_02b --- src/MLP.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/MLP.py diff --git a/src/MLP.py b/src/MLP.py new file mode 100644 index 0000000..dabd88c --- /dev/null +++ b/src/MLP.py @@ -0,0 +1,46 @@ +import numpy as np + +class Perceptron: + """A single neuron with the sigmoid activation function. + Attributes: + inputs: The number of inputs in the perceptron, not counting the bias. + bias: The bias term. By defaul it's 1.0.""" + + def __init__(self, inputs, bias = 1.0): + """Return a new Perceptron object with the specified number of inputs (+1 for the bias).""" + self.weights = (np.random.rand(inputs+1) * 2) - 1 + self.bias = bias + + def run(self, x): + """Run the perceptron. x is a python list with the input values.""" + sum = np.dot(np.append(x,self.bias),self.weights) + return self.sigmoid(sum) + + def set_weights(self, w_init): + """Set the weights. w_init is a python list with the weights.""" + self.weights = np.array(w_init) + + def sigmoid(self, x): + """Evaluate the sigmoid function for the floating point input x.""" + return 1/(1+np.exp(-x)) + + + +class MultiLayerPerceptron: + """A multilayer perceptron class that uses the Perceptron class above. + Attributes: + layers: A python list with the number of elements per layer. + bias: The bias term. The same bias is used for all neurons. + eta: The learning rate.""" + + def __init__(self, layers, bias = 1.0): + """Return a new MLP object with the specified parameters.""" + self.layers = np.array(layers,dtype=object) + self.bias = bias + self.network = [] # The list of lists of neurons + self.values = [] # The list of lists of output values + + + + self.network = np.array([np.array(x) for x in self.network],dtype=object) + self.values = np.array([np.array(x) for x in self.values],dtype=object) From 57d3f100efb8399dd23f99b86f5b568d04968da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Corpe=C3=B1o?= Date: Mon, 5 Sep 2022 16:49:27 -0600 Subject: [PATCH 2/5] Update Dockerfile --- .devcontainer/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 0a5d35d..a507788 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -12,6 +12,7 @@ RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/ # COPY requirements.txt /tmp/pip-tmp/ # RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ # && rm -rf /tmp/pip-tmp +RUN pip3 install numpy # [Optional] Uncomment this section to install additional OS packages. # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ From 4be2da343afd5f7d11394b20dd958e1108ce27db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Corpe=C3=B1o?= Date: Wed, 7 Sep 2022 13:16:05 -0600 Subject: [PATCH 3/5] updated for Codespaces --- .vscode/settings.json | 3 ++- src/MLP.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2369810..e879633 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -20,5 +20,6 @@ "workbench.activityBar.visible": true, "workbench.colorTheme": "Visual Studio Dark", "workbench.fontAliasing": "antialiased", - "workbench.statusBar.visible": true + "workbench.statusBar.visible": true, + "python.linting.pylintCategorySeverity.convention": "Hint" } diff --git a/src/MLP.py b/src/MLP.py index dabd88c..d4faf91 100644 --- a/src/MLP.py +++ b/src/MLP.py @@ -4,7 +4,7 @@ class Perceptron: """A single neuron with the sigmoid activation function. Attributes: inputs: The number of inputs in the perceptron, not counting the bias. - bias: The bias term. By defaul it's 1.0.""" + bias: The bias term. By default it's 1.0.""" def __init__(self, inputs, bias = 1.0): """Return a new Perceptron object with the specified number of inputs (+1 for the bias).""" @@ -13,8 +13,8 @@ def __init__(self, inputs, bias = 1.0): def run(self, x): """Run the perceptron. x is a python list with the input values.""" - sum = np.dot(np.append(x,self.bias),self.weights) - return self.sigmoid(sum) + x_sum = np.dot(np.append(x,self.bias),self.weights) + return self.sigmoid(x_sum) def set_weights(self, w_init): """Set the weights. w_init is a python list with the weights.""" From bd42bbd2aedf09d0972da462e9ff0958ce154294 Mon Sep 17 00:00:00 2001 From: smoser-LiL Date: Mon, 7 Nov 2022 16:17:14 +0000 Subject: [PATCH 4/5] Moving files using main --- NOTICE | 3 --- README.md | 27 ++++++++++++++------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/NOTICE b/NOTICE index 547595f..4851a73 100644 --- a/NOTICE +++ b/NOTICE @@ -4,9 +4,6 @@ All Rights Reserved. Licensed under the LinkedIn Learning Exercise File License (the "License"). See LICENSE in the project root for license information. -ATTRIBUTIONS: -[PLEASE PROVIDE ATTRIBUTIONS OR DELETE THIS AND THE ABOVE LINE “ATTRIBUTIONS”] - Please note, this project may automatically load third party code from external repositories (for example, NPM modules, Composer packages, or other dependencies). If so, such third party code may be subject to other license terms than as set diff --git a/README.md b/README.md index e0e8230..7ca9522 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,12 @@ -# Training Neural Networks in Python -This is the repository for the LinkedIn Learning course `Training Neural Networks in Python`. The full course is available from [LinkedIn Learning][lil-course-url]. +# Training Neural Networks in Python +This is the repository for the LinkedIn Learning course Training Neural Networks in Python . The full course is available from [LinkedIn Learning][lil-course-url]. + +![Training Neural Networks in Python ][lil-thumbnail-url] + +Having a variety of great tools at your disposal isn’t helpful if you don’t know which one you really need, what each tool is useful for, and how they all work. In this course learn the inner workings of neural networks, so that you're able to work more effectively with machine learning tools. Instructor Eduardo Corpeño helps you learn by example by providing a series of exercises in Python to help you to grasp what’s going on inside. Discover how to relate parts of a biological neuron to Python elements, which allows you to make a model of the brain. Then, learn how to build and train a network, as well as create a neural network that recognizes numbers coming from a seven-segment display. Even though you'll probably work with neural networks from a software suite rather than by writing your own code, the knowledge you’ll acquire in this course can help you choose the right neural network architecture and training method for each problem you face. +

+This course is integrated with GitHub Codespaces, an instant cloud developer environment that offers all the functionality of your favorite IDE without the need for any local machine setup. With GitHub Codespaces, you can get hands-on practice from any machine, at any time—all while using a tool that you’ll likely encounter in the workplace. Check out the [Using GitHub Codespaces with this course][gcs-video-url] video to learn how to get started. -_See the readme file in the main branch for updated instructions and information._ ## Instructions This repository has branches for each of the videos in the course. You can use the branch pop up menu in github to switch to a specific branch and take a look at the course at that stage, or you can add `/tree/BRANCH_NAME` to the URL to go to the branch you want to access. @@ -19,16 +24,12 @@ To resolve this issue: Add changes to git using this command: git add . Commit changes using this command: git commit -m "some message" +### Instructor -## Installing -1. To use these exercise files, you must have the following installed: - - [list of requirements for course] -2. Clone this repository into your local machine using the terminal (Mac), CMD (Windows), or a GUI tool like SourceTree. -3. [Course-specific instructions] - - -[0]: # (Replace these placeholder URLs with actual course URLs) +Eduardo Corpeno -[lil-course-url]: https://www.linkedin.com/learning/ -[lil-thumbnail-url]: http:// +Check out my other courses on [LinkedIn Learning](https://www.linkedin.com/learning/instructors/eduardo-corpeno?u=104). +[lil-course-url]: https://www.linkedin.com/learning/training-neural-networks-in-python-17058600 +[lil-thumbnail-url]: https://media.licdn.com/dms/image/C560DAQEETI1NQkDM_A/learning-public-crop_675_1200/0/1666380611131?e=1667955600&v=beta&t=r_clO_ruck-0tner2KRxC6ypQuy21uOh_XtI5NTr_zs +[gcs-video-url]: https://www.linkedin.com/learning/training-neural-networks-in-python-17058600/using-github-codespaces-with-this-course From 4d72c0d8e8f94334d63b47b53102a93282ed192c Mon Sep 17 00:00:00 2001 From: smoser-LiL Date: Tue, 8 Nov 2022 22:53:35 +0000 Subject: [PATCH 5/5] Moving files using main --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7ca9522..140f1d8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Training Neural Networks in Python -This is the repository for the LinkedIn Learning course Training Neural Networks in Python . The full course is available from [LinkedIn Learning][lil-course-url]. +This is the repository for the LinkedIn Learning course Training Neural Networks in Python. The full course is available from [LinkedIn Learning][lil-course-url]. ![Training Neural Networks in Python ][lil-thumbnail-url] @@ -31,5 +31,5 @@ Eduardo Corpeno Check out my other courses on [LinkedIn Learning](https://www.linkedin.com/learning/instructors/eduardo-corpeno?u=104). [lil-course-url]: https://www.linkedin.com/learning/training-neural-networks-in-python-17058600 -[lil-thumbnail-url]: https://media.licdn.com/dms/image/C560DAQEETI1NQkDM_A/learning-public-crop_675_1200/0/1666380611131?e=1667955600&v=beta&t=r_clO_ruck-0tner2KRxC6ypQuy21uOh_XtI5NTr_zs +[lil-thumbnail-url]: https://cdn.lynda.com/course/3215347/3215347-1667864479246-16x9.jpg [gcs-video-url]: https://www.linkedin.com/learning/training-neural-networks-in-python-17058600/using-github-codespaces-with-this-course