Neural Network (or Net for short) is a C++ class providing a generic interface for training and executing simple backpropagation neural networks, for performing a variety of tasks, based loosely upon code by Karsten Kutza from here.
Source is available here (see below for packages):
Net.h
(view html)
Net.cpp
(view html)
NetLayer.cpp
(view html)
backprop.cpp
(view html)
Makefile
(view html)
or here as a package:
| File |
Size |
| nnetwork.zip |
13871 |
| nnetwork.tar.gz |
9061 |
| nnetwork.tar.bz2 |
8854 |
The neural network class itself is the class NeuralNetwork::Net.
It depends on the class NeuralNetwork::NetLayer, both of which
are defined in Net.h. The file backprop.cpp is a sample of
using Net to train a system to predict sunspot patterns, and
Makefile is used to build the sample application on platforms with
make.
I will assume you are already familiar with neural networks in the following description of how to typically use the classes:
NeuralNetwork::Net, passing in the number of layers,
number of perceptrons in each layer, momentum factor, learning rate,
and gain for the sigmoid function.
Net::randomizeWeights() or Net::clearWeights().NeuralNetwork::ExampleFactory and
implement getExample, which returns via its parameters a new
input/output pair each time it's called, and numExamples, which
is an estimate of the total number of unique examples.autotrain.Net::autotrain() to train the network to its optimum error level
on the test set. It will perform a specified number of epochs, then test if
error on the test set has exceeded minimum error times the specified cut off error.
If so, it will consider training done, and return with the network configured
to the weights that gave best results on the test set. Otherwise, it will repeat.Net::doneTraining() to dispose of temporary storage used during training.Net::run(), which simply
takes an input and produces an output.Net::save()
with a binary-mode std::ostream. Load it again using the Net constructor
taking a binary-mode istream.Since you might wish to observe the progress of your network's training, you may #define
the symbol NEURAL_NET_DEBUG to view the total error each time it is calculated
for the test set. When this starts to go up, training is nearing completion.