AI-NeuralNet-Simple
view release on metacpan or search on metacpan
--- #YAML:1.0
name: AI-NeuralNet-Simple
version: 0.11
abstract: An easy to use backprop neural net.
license: perl
generated_by: ExtUtils::MakeMaker version 6.31
distribution_type: module
requires:
Log::Agent: 0.208
Sub::Uplevel: 0
Test::Exception: 0.15
Test::More: 0.48_01
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.2.html
version: 1.2
author:
- Curtis "Ovid" Poe <ovid@cpan.org>
AI/NeuralNet/Simple version 0.01
================================
This is a simple backprop neural net simply for experimentation purposes.
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
DEPENDENCIES
This module requires these other modules and libraries:
#include "XSUB.h"
/*
* Macros and symbolic constants
*/
#define RAND_WEIGHT ( ((float)rand() / (float)RAND_MAX) - 0.5 )
#define sqr(x) ((x) * (x))
typedef struct {
double **input_to_hidden;
double **hidden_to_output;
} SYNAPSE;
SYNAPSE weight;
typedef struct {
double *hidden;
double *output;
} ERROR;
ERROR error;
typedef struct {
double *input;
double *hidden;
double *output;
double *target;
} LAYER;
LAYER neuron;
typedef struct {
int input;
int hidden;
int output;
} NEURON_COUNT;
typedef struct {
float learn_rate;
double delta;
int use_bipolar;
SYNAPSE weight;
ERROR error;
LAYER neuron;
NEURON_COUNT size;
double *tmp;
} NEURAL_NETWORK;
lib/AI/NeuralNet/Simple.pm view on Meta::CPAN
foreach (input.neuron)
output += input.neuron.output * input.neuron.synapse.weight
ouput = activation_function(output)
The "activation function" is a special function that is applied to the inputs
to generate the actual output. There are a variety of activation functions
available with three of the most common being the linear, sigmoid, and tahn
activation functions. For technical reasons, the linear activation function
cannot be used with the type of network that C<AI::NeuralNet::Simple> employs.
This module uses the sigmoid activation function. (More information about
these can be found by reading the information in the L<SEE ALSO> section or by
just searching with Google.)
Once the activation function is applied, the output is then sent through the
next synapse, where it will be multiplied by w4 and the process will continue.
=head2 C<AI::NeuralNet::Simple> architecture
The architecture used by this module has (at present) 3 fixed layers of
lib/AI/NeuralNet/Simple.pm view on Meta::CPAN
the expected results:
input output
1 2 1 2
----- ------
1 1 0 1
1 0 0 1
0 1 0 1
0 0 1 0
The type of network we use is a forward-feed back error propagation network,
referred to as a back-propagation network, for short. The way it works is
simple. When we feed in our input, it travels from the input to hidden layers
and then to the output layers. This is the "feed forward" part. We then
compare the output to the expected results and measure how far off we are. We
then adjust the weights on the "output to hidden" synapses, measure the error
on the hidden nodes and then adjust the weights on the "hidden to input"
synapses. This is what is referred to as "back error propagation".
We continue this process until the amount of error is small enough that we are
satisfied. In reality, we will rarely if ever get precise results from the
lib/AI/NeuralNet/Simple.pm view on Meta::CPAN
The C code in this module is based heavily upon Mr. Jones backpropogation
network in the book. The "game ai" example in the examples directory is based
upon an example he has graciously allowed me to use. I I<had> to use it
because it's more fun than many of the dry examples out there :)
"Naturally Intelligent Systems", by Maureen Caudill and Charles Butler,
copyright (c) 1990 by Massachussetts Institute of Technology.
This book is a decent introduction to neural networks in general. The forward
feed back error propogation is but one of many types.
=head1 AUTHORS
Curtis "Ovid" Poe, C<ovid [at] cpan [dot] org>
Multiple network support, persistence, export of MSE (mean squared error),
training until MSE below a given threshold and customization of the
activation function added by Raphael Manfredi C<Raphael_Manfredi@pobox.com>.
=head1 COPYRIGHT AND LICENSE
( run in 2.351 seconds using v1.01-cache-2.11-cpan-df04353d9ac )