AI-NNFlex
view release on metacpan or search on metacpan
lib/AI/NNFlex.pm view on Meta::CPAN
return 1;
}
1;
=pod
=head1 NAME
AI::NNFlex - A base class for implementing neural networks
=head1 SYNOPSIS
use AI::NNFlex;
my $network = AI::NNFlex->new(config parameter=>value);
$network->add_layer( nodes=>x,
activationfunction=>'function');
$network->init();
$network->lesion( nodes=>PROBABILITY,
connections=>PROBABILITY);
$network->dump_state (filename=>'badgers.wts');
$network->load_state (filename=>'badgers.wts');
my $outputsRef = $network->output(layer=>2,round=>1);
=head1 DESCRIPTION
AI::NNFlex is a base class for constructing your own neural network modules. To implement a neural network, start with the documentation for AI::NNFlex::Backprop, included in this distribution
=head1 CONSTRUCTOR
=head2 AI::NNFlex->new ( parameter => value );
randomweights=>MAXIMUM VALUE FOR INITIAL WEIGHT
fixedweights=>WEIGHT TO USE FOR ALL CONNECTIONS
debug=>[LIST OF CODES FOR MODULES TO DEBUG]
round=>0 or 1, a true value sets the network to round output values to nearest of 1, -1 or 0
The constructor implements a fairly generalised network object with a number of parameters.
The following parameters are optional:
randomweights
fixedweights
debug
round
(Note, if randomweights is not specified the network will default to a random value from 0 to 1.
=head1 METHODS
This is a short list of the main methods implemented in AI::NNFlex.
=head2 AI::NNFlex
=head3 add_layer
Syntax:
$network->add_layer( nodes=>NUMBER OF NODES IN LAYER,
persistentactivation=>RETAIN ACTIVATION BETWEEN PASSES,
decay=>RATE OF ACTIVATION DECAY PER PASS,
randomactivation=>MAXIMUM STARTING ACTIVATION,
threshold=>NYI,
activationfunction=>"ACTIVATION FUNCTION",
randomweights=>MAX VALUE OF STARTING WEIGHTS);
Add layer adds whatever parameters you specify as attributes of the layer, so if you want to implement additional parameters simply use them in your calling code.
Add layer returns success or failure, and if successful adds a layer object to the $network->{'layers'} array. This layer object contains an attribute $layer->{'nodes'}, which is an array of nodes in the layer.
=head3 init
Syntax:
$network->init();
Initialises connections between nodes, sets initial weights. The base AI::NNFlex init method implementes connections backwards and forwards from each node in each layer to each node in the preceeding and following layers.
init adds the following attributes to each node:
=over
=item *
{'connectedNodesWest'}->{'nodes'} - an array of node objects connected to this node on the west/left
=item *
{'connectedNodesWest'}->{'weights'} - an array of scalar numeric weights for the connections to these nodes
=item *
{'connectedNodesEast'}->{'nodes'} - an array of node objects connected to this node on the east/right
=item *
{'connectedNodesEast'}->{'weights'} - an array of scalar numeric weights for the connections to these nodes
=back
The connections to easterly nodes are not used in feedforward networks.
Init also implements the Bias node if specified in the network config.
=head3 connect
Syntax:
$network->connect(fromlayer=>1,tolayer=>0);
$network->connect(fromnode=>'1,1',tonode=>'0,0');
Connect allows you to manually create connections between layers or nodes, including recurrent connections back to the same layer/node. Node indices must be LAYER,NODE, numbered from 0.
( run in 0.767 second using v1.01-cache-2.11-cpan-39bf76dae61 )