(C++) Neural network
January 7, 2018 · View on GitHub
(C++) Neural network
A neural network is a connected collection of neurons (that is, a class that simulates a biological neuron) that can be trained for certain purposes.
Freely downloadable C++ neural networks
From my favorite (top) to my least favorite. This list is incomplete and will remain incomplete.
- Shark: my personal favorite machine learning network, because it suits my needs
- Flood: the neural network implementation I used when using C++ Builder 6.0. Downsides are const-incorrectness, the use of STL functions without 'std::' in front of it (a simple replace command fixes this, though), the use of handcrafted classes (for example Flood::Vector, instead of std::vector), dirty C-style casts and few documentation. Don't mind me nitpicking: because I use it with much pleasure, I know this one best!
- FANN: programmed in C, I found it too hard to use for my own needs.
- http://www.bedaux.net/nnet: takes boolians as input and produces boolians as output.
- http://www.codeproject.com/cpp/MLP.asp: good code if you like the way Visual C++ handles its GUI
- http://sourceforge.net/project/showfiles.php?group_id=10202&package_id=10051&release_id=10643: Average implementation relying heavily on plain pointers
- http://members.tripod.com/~zerkpage/backprop.txt fair code which is easy to read, but uses many global pointers
- http://sourceforge.net/projects/nn-utility: acceptable source code, except for use of pointers-to-pointers-to-pointers, class names in UPPERCASE
- http://www.paraschopra.com/sourcecode/index.php: example how NOT to program: use of macro's, explicit write of void as a function argument, inconsistent indentation, etc...
Untested:
- Annie (http://annie.sourceforge.net)
Proposed neural network architecture
template <class Neuron> struct NeuralNetwork { NeuralNetwork( const int nInputs = 0, const int nHidden = 0, const int nOutputs = 0); //If the propagation of a neuron does not change its state, //NeuralNet::Propagate is a const method //Note: this constness must be determined by templates const std::vector<double> Propagate(const std::vector<double>& inputs); const std::vector<double> Propagate(const std::vector<double>& inputs) const; //When a desired input is known, let this backpropagate void BackPropagate(const std::vector<double>& desiredOutputs) private: //The NeuralNetwork is implemented as a boost::graph of Neurons boost::graph<Neuron> m_n; }; //Neuron is an abstract base class struct Neuron { //Note: this constness must be determined by templates double Propagate(const double input) = 0; double Propagate(const double input) const = 0; };
External links