This GitHub repository contains the code for a simple Backpropagation neural network written in Python. The project's goal is to investigate the changes in learning when noise is present in inputs and/or target data. The neural network has only one unit with a sigmoid activation function.
For this project, we implement a 2-input single unit Backpropagation neural network with a sigmoid activation function. The system reads data from a file named "training.txt" and reads parameters from another file named "params.txt." The parameters include initial weights and learning rate. The project uses a batch size of 1, meaning weights are updated for each example, and an epoch represents one complete run through the training set.
The error measure used is the sum-of-squares-of-errors (SSE) or mean-squared-error (MSE) calculated over the entire training set. The expectation is that this error will decrease with training. During training, weights and errors are printed out after 2, 4, 8, 16, 32, etc., epochs and saved in a file named "XXXXresults1.txt,"
Additionally, the project includes a testing phase where the network's ability to learn predefined weights is evaluated using different sets of initial weights and training data.
The Python code in this repository is responsible for implementing and training the neural network. It includes functions for the sigmoid activation, its derivative, mean-squared-error loss, feedforward pass, backward pass, and the training process.
# Python code here
To get started with this project, follow these steps:
-
Clone this repository to your local machine using the following command:
git clone <repository-url>
-
Make sure you have Python and required dependencies installed on your system.
-
Prepare your data files:
- Create a "training.txt" file with your training data.
- Create a "params.txt" file with initial weights and learning rate.
-
Run the Python code to train the neural network.
To use this project for your own experiments:
-
Prepare your training and validation data in the required format.
-
Adjust the initial weights and learning rate in the "params.txt" file.
-
Modify any other parameters in the Python code as needed for your specific use case.
-
Run the Python script to train and evaluate the neural network.
The results of the training and validation runs, including weights and errors, will be saved in "SRNresults1.txt" and plotted on a log/log scale.
This project is licensed under the MIT License.
This project is part of a coding assignment. Credits to the assignment creator and the educational institution.
Feel free to explore and modify this project for your own learning and research purposes!