top of page
Search

Project 1 - A Simple Neural Network - XOR logic

  • Writer: James Canova
    James Canova
  • Sep 25, 2021
  • 2 min read

Updated: Apr 3, 2024

Project start: 1 July 2021

Project finish: 10 October 2021


Last updated: 30 March 2024


Objective: familiarisation with basic neural networks an embedded computing


This is my first neural network project. Project 1a is using a Pyboard and Project 1b is using a Rasperry Pi Pico. Micropython is used in both projects.


To get started I strongly recommend reading the book, Make Your Own Neural Network.


I'm using a 10 year old Lenovo T420 laptop with Ubuntu 18.04 LTS.


The board is a Pyboard V1.1.8.


In this project you will learn how to implement a very simple neural network, specifically a two input, one output, XOR logic routine. Using a neural network for this problem is excessive but instructive.


The neural network:


The Neural Network

The dataset (i.e. the inputs and outputs used for training)

The neural network is trained and then queried or in other words, outputs are inferred by the neural network.


Install the Thonny IDE:


Thonny is a free and very easy to use IDE. It's more than adequate for this project.


Install pip3:

$ pip install -U pip

Installation of pip3 can be checked with:

$ pip3 -V

Install setuptools:

$pip3 install -U  testresources

$pip3 install -U setuptools

Install Thonny:

$pip3 install thonny

Installation of Thonny can be checked with:

$ pip3 show thonny

Setup permission for connection between host and Pyboard:

$ sudo usermod -a -G dialout <your user-name> 

(note: in Ubuntu use "whoami" to display your user name)


To use:


Connect the USB cable to microcontroller.


Check the connection between the host and microcontroller:

$ ls -l /dev/ttyACM*
crw-rw---- 1 <your user-name> root dialout 166, 0 Oct 12 11:15 /dev/ttyACM0

Note:

Below is the neural network program as a Jupyter-Notebook file written in Python as opposed to MicroPython.


It includes a graph of the error in results during training which I used to determine the number of training cycles (and some other parameters) required to generate good weights and bias values.


If you are new to Python, it might be easiest to use Google Colaboratory to run the program. You will need a Google Account to do this.


To use Google Colaboratory, unzip and upload the file below to your Google Drive. Right click and open with Google Colaboratory.




If you have any problems or need clarification please contact me: jscanova@gmail.com

















 
 
 

Recent Posts

See All
Introduction

I became interested in artificial intelligence in mid 2021 after watching a documentary on this subject. In particular, I'm interested in...

 
 
 
References

1.Rashid, Tariq, Make Your Own Neural Network , Amazon , 2016 2.Portilla, Jose, "Python for Computer Vision with OpenCV and Deep...

 
 
 
Status of Projects

Last updated: 30 March 2024 Project 0: Read this to get a very basic understating on machine learning and neural networks. Project 1:...

 
 
 

Comments


Post: Blog posts

©2021 by My Machine Learning Blog. Proudly created with Wix.com

bottom of page