This project is a simple implementation of a neural network from scratch. The neural network is capable of performing binary classification tasks. It uses the concept of artificial neurons and backpropagation to learn from input data and make predictions.
To get started with this project, you can follow the instructions below.
Make sure you have the following dependencies installed:
- Python 3.x
- NumPy
-
Clone the repository:
git clone <repository_url>
-
Navigate to the project directory:
cd neural-network-from-scratch
-
Install the required dependencies:
pip install numpy
To use the neural network, follow these steps:
-
Import the necessary modules:
import math import numpy as np
-
Copy the code for the
Connection
,Neuron
, andNetwork
classes into your Python script or notebook. -
Create an instance of the
Network
class with the desired dimensions for the neural network:network = Network([input_size, hidden_size, output_size])
-
Set the input values for the network:
network.setInput(inputs)
-
Activate the network:
network.activate()
-
Perform backpropagation by providing the target output values:
network.backpropagate(targets)
-
Access the predicted output values:
predictions = network.getPredictions()
-
Continue training the network by iterating over the data and adjusting the weights until the desired loss is achieved.
Here's an example of how to use the neural network:
# Import the necessary modules
import math
import numpy as np
# Copy the code for the Connection, Neuron, and Network classes
# Create an instance of the Network class
network = Network([2, 1])
# Set the input values
inputs = [0, 1]
network.setInput(inputs)
# Activate the network
network.activate()
# Perform backpropagation
targets = [1]
network.backpropagate(targets)
# Get the predicted output values
predictions = network.getPredictions()
# Print the predictions
print(predictions)