-
Notifications
You must be signed in to change notification settings - Fork 2
Tutorial #1 Basic usage of the Neural Network
To include the Neural Network into your own project, copy the library/header
folder into your project folder and include the file NeuralNetwork.hpp into your source file.
Folder Structure:
MyProject>
->zeneural
---->Contents of library/header
->mySourceFile.cpp
mySourceFile.cpp:
#include "zeneural/NeuralNetwork.hpp```
.
.
.
The entire Library is encapsulated into the Namespace ZNN.
Artificial neural networks (ANN) or connectionist systems are computing systems vaguely inspired by the biological neural networks that constitute animal brains.[1] Such systems "learn" to perform tasks by considering examples, generally without being programmed with any task-specific rules. For example, in image recognition, they might learn to identify images that contain cats by analyzing example images that have been manually labeled as "cat" or "no cat" and using the results to identify cats in other images. They do this without any prior knowledge about cats, e.g., that they have fur, tails, whiskers and cat-like faces. Instead, they automatically generate identifying characteristics from the learning material that they process.
Basically, you can imagine a Neural Network as a mathematical model that learns to improve it's predictive capabilities. Or simpler: You show it examples and tell it what it should output until it becomes better and better at guessing.
A NN consists of different layers. Each layer consists of a variable amount of Neurons.
There are three types of layers:
- Input Layers (amount: exactly one)
- Hidden Layers (amount: any positive amount)
- Output Layers (amount: exactly one)
Neurons are linked together by weights.
In order to use the NN, you have to create an object from class ZNN::NeuralNetwork. It takes as template argument the Datatype to work with (this means that you can use gmp to make the NN work on super high presicions).
ZNN::NeuralNetwork<double> firstNN{};
You can now proceed to add layers to it. You have to do it in the following order:
- Input Layer
- Hidden Layer (s)
- Output Layer
To add an Input Layer, you use
ZNN::NeuralNetwork<floatType>::setInputLayerSize(unsigned int layerSize)
To add a Hidden Layer, you use
ZNN::NeuralNetwork<floatType>::addHiddenLayer (unsigned int layerSize)
To add an Output Layer, you use
ZNN::NeuralNetwork<floatType>::setOutputLayerSize(unsigned int layerSize)
To create a simple Neural Network that can evaluate a XOR, you could use this NN-Structure:
ZNN::NeuralNetwork<double> xorNN;
xorNN.setInputLayerSize(2);
xorNN.addHiddenLayer(4);
xorNN.setOutputLayerSize(1);