The repository contains projects related to data science.
This project demonstrates a simple neural network trained to recognize images of letters A, B, and C using Python and NumPy.
The dataset consists of three images:
- A: Represented as a list a
- B: Represented as a list b
- C: Represented as a list c Each letter is encoded as a binary image in a 1-dimensional NumPy array format.
The labels for the images are:
- A: [1, 0, 0]
- B: [0, 1, 0]
- C: [0, 0, 1]
- Input Layer: 30 neurons (corresponding to 30 pixels in each image)
- Hidden Layer: 5 neurons, activated using the sigmoid function
- Output Layer: 3 neurons (one for each letter), activated using the sigmoid function
The neural network is trained using backpropagation with gradient descent -
- Loss Function: Mean Squared Error (MSE)
- Activation Function: Sigmoid Training Parameters:
- Learning Rate (α): 0.1
- Epochs: 100
After training for 100 epochs, the neural network achieved an accuracy of 95.67% on the training dataset.
To use the trained model for prediction:
print("Testing the trained neural network:")
test_samples = [np.array(a).reshape(1,30), np.array(b).reshape(1,30), np.array(c).reshape(1,30)]
for sample in test_samples:
predict(sample, w1, w2)predict(x[0], w1, w2) # Image is of letter A
predict(x[1], w1, w2) # Image is of letter B
predict(x[2], w1, w2) # Image is of letter C
