Skip to content

This is a multi-layer-perceptron built using only python and numpy. It is designed to predict an XOR pattern, but could be reconfigured for a few different logical gates.

License

Notifications You must be signed in to change notification settings

RyanSonder/xor-mlp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Layer Perceptron for XOR Logic Gate

This file has my implmentation of a multi-layer perceptron set up to train on data pertaining to the XOR logic gate. Minor alterations to the training data could change this model to work with AND, OR, and other two-input logic gates.

As we discussed in class, the model uses repeated forward and backward propagation to to train. There are a couple of parameters that can be altered to slightly tweak the training, that being epochs, the number of training sets performed, and learning_rate, the proportion by which updates affect the network. Currently, those values are set to:

    epochs = 100000
    learning_rate = 0.1

The MLP has the following structure:

Structure of the MLP

Output

When given the aforementioned values of epochs and learning_rate, the following output is printed in the terminal.

Snippet of the MLP working in terminal

With a higher number of epochs, the predictions would be more accurate, but the model will take longer to train. I tested the same code with

    epochs = 1000000

and obtained the following result

Snippet of the MLP working in terminal

As can be seen, the results are closer to the expected value, but not by much. Thus, while there is some value to increasing the number of epochs, the returns are diminishing. Overall, the model is very accurate.

Usage

To run this module, ensure that you have numpy installed:

    pip install numpy

Run the xor-mlp.py to train the MLP and evaluate its performance.

About

This is a multi-layer-perceptron built using only python and numpy. It is designed to predict an XOR pattern, but could be reconfigured for a few different logical gates.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages