Ken-Soft

Software and the World


Neural Network (Back-Error Propagation) C++

Posted under Artificial Intelligence, C/C++, General Development, Neural Networks, Programming, Software Development by Kenny on Sunday 20 December 2009 at 4:42 am

Bookmark and Share

Here is yet another simple Neural Network that implements Back-Error Propagation as a form of Reinforced Learning.
The entire project is written in C++ and requires no special libraries to compile and run.
main.cpp contains code to train both a 2 and 3-input Logical AND gate.
The zipped source code can be downloaded here
A Linux executable is already compiled and included in the zip, but feel free to recompile it. A Code::Blocks Project file is also included.

To Compile
g++ *.cpp -o NeuralNetwork
It will output an executable name “NeuralNetwork”
To Run
open a terminal and type:
./NeuralNetwork
Sample Output
Neural Network Connections Inited
Trained in 10000 trails within an error of 1.03127e-05
0 & 0 = 4.63117e-05
0 & 1 = 0.00349833
1 & 0 = 0.00290835
1 & 1 = 0.995469
Train Logical AND 2 Inputs Demo End
Neural Network Connections Inited
Training...
Trained in 5584 trails within an error of 9.99977e-06
0 & 0 & 0 = 3.62242e-05
0 & 0 & 1 = 0.00194301
0 & 1 & 0 = 0.000102096
0 & 1 & 1 = 0.00344352
1 & 0 & 0 = 0.000142368
1 & 0 & 1 = 0.00333881
1 & 1 & 0 = 0.0035418
1 & 1 & 1 = 0.993633
Logical AND 3 Inputs Demo End

Resources:
About Neural Networks (English)
About Neural Networks (Japanese/日本語)
Java Implementation of a Neural Network

Share on Facebook

Load Neural Network Training data from XML (PDF)

Posted under Artificial Intelligence, General Development, Neural Networks, Programming, Software Development, XML by Kenny on Thursday 25 December 2008 at 10:05 pm

Bookmark and Share




Share on Facebook

Neural Network - Load Train Data from XML - Java

Posted under Artificial Intelligence, General Development, Java, Neural Networks, Programming, Software Development by Kenny on Thursday 25 December 2008 at 9:52 pm

Bookmark and Share

This Neural Network is a command line implementation that uses the Back-Error Propagation learning algorithm. The main difference with this model is that all train data is loaded from an external XML file.
The Train data specification can be found Here.

The Zip file containing the Jar file and traindata directory can be downloaded here: NN.jar
Below is the Syntax for running NN02.jar in a command line:
java -jar NN02.jar [num center layers] [num center layer neurons] [learning rate]
An example includes:
java -jar NN02.jar 1 50 1.5
Which specifies a neural network with 1 center layers, 50 neurons per center layer, and a learning rate of 1.5. If now parameters are supplied it runs with default parameters.
Once executed, it should give a display similar to the image below.

The neural network Source is almost unchanged from a previous example found Here
Included in the zip file is my custom, and very very messy, XML Parser. If you plan on using any of this code for any real development, I recommend using a standard XML Parser. :)

Share on Facebook

Next Page »

Copyright © 2009 www.Ken-Soft.com