This repository showcases a basic neural network designed to learn and predict the output of an XOR-Gate. It serves as an excellent introductory project for anyone looking to dive into the world of neural networks. Start your journey here with this simple yet fundamental 'Hello, World' example in neural networking.
- Fork and clone the repository.
- Follow the steps to generate the training data.
- Execute the code using the following instructions.
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
int main() {
cout << "topology: 2 4 1" << endl;
for(int i = 10000; i >= 0; --i) {
int n1 = (int) (2.0 * rand() / double(RAND_MAX));
int n2 = (int) (2.0 * rand() / double(RAND_MAX));
int t = n1 ^ n2; // bitwise XOR
cout << "in: " << n1 << ".0 " << n2 << ".0 " << endl;
cout << "out: " << t << ".0" << endl;
}
}
g++ yourFileName.cpp -o makeTraingSamples
./makeTraingSamples > trainingData.txt
cd XORGate-NeuralNetwork
cmake --build cmake-build-debug
./cmake-build-debug/XORGate_NeuralNetwork
If the training file cannot be found, please ensure that the file is in the same directory from which you are executing the command. For example, if you are using CLion, you may need to move the file into the cmake-build-debug folder.
Feel free to reach out if you have any questions or encounter any issues. Happy coding!