A lightweight, from-scratch implementation of a feedforward neural network in pure C. This project demonstrates the fundamental principles of neural networks by teaching a simple model to solve the classic XOR problem.
- Pure C: Built with only standard C libraries (
stdlib.h,stdio.h,math.h). No heavy dependencies! - Feedforward Architecture: A simple and classic neural network structure with an input layer, a hidden layer, and an output layer.
- Backpropagation Algorithm: Learns from its mistakes by propagating errors backward through the network to adjust weights and biases.
- Sigmoid Activation: Uses the sigmoid function to introduce non-linearity, allowing it to learn complex patterns.
- Stochastic Training: Shuffles the training data for each epoch to prevent the model from getting stuck in local minima and improve generalization.
You can compile and run this project with any standard C compiler like GCC.
- A C compiler (e.g., GCC)
-
Clone the repository:
git clone [https://github.com/Anjas2005/Neural-Network-in-C.git](https://github.com/Anjas2005/Neural-Network-in-C.git) cd Neural-Network-in-C -
Compile the C code. The
-lmflag is necessary to link the math library.gcc main.c -o neural_network -lm
Run the compiled executable from your terminal:
./neural_network