AI::NNFlex - A customisable neural network simulator
use AI::NNFlex; my $network = AI::NNFlex->new(config parameter=>value); $network->add_layer(nodes=>x,activationfunction=>'function'); $network->init(); use AI::NNFlex::Dataset; my $dataset = AI::NNFlex::Dataset->new([ [INPUTARRAY],[TARGETOUTPUT], [INPUTARRAY],[TARGETOUTPUT]]); my $sqrError = 10; while ($sqrError >0.01) { $sqrError = $dataset->learn($network); } $network->lesion({'nodes'=>PROBABILITY,'connections'=>PROBABILITY}); $network->dump_state(filename=>'badgers.wts'); $network->load_state(filename=>'badgers.wts'); my $outputsRef = $dataset->run($network);
AI::NNFlex is intended to be a highly flexible, modular NN framework. It's written entirely in native perl, so there are essentially no prereq's. The following modular divisions are made: * NNFlex.pm the core module. Contains methods to construct and lesion the network * feedforward.pm the network type module. Feedforward is the only type currently defined, but others may be created and imported at runtime * <learning>.pm the learning algorithm. Currently the options are backprop - standard vanilla backprop momentum - backprop with momentum * <activation>.pm node activation function. Currently the options are tanh, linear & sigmoid. * Dataset.pm methods for constructing a set of input/output data and applying to a network. The code should be simple enough to use for teaching purposes, but a simpler implementation of a simple backprop network is included in the example file bp.pl. This is derived from Phil Brierleys freely available java code at www.philbrierley.com. AI::NNFlex leans towards teaching NN and cognitive modelling applications. Future modules are likely to include more biologically plausible nets like DeVries & Principes Gamma model.
new ( parameter => value ); randomweights=>MAXIMUM VALUE FOR INITIAL WEIGHT learningalgorithm=>The AI::NNFlex module to import for training the net networktype=>The AI::NNFlex module to import for flowing activation debug=>[LIST OF CODES FOR MODULES TO DEBUG] learningrate=>the learning rate of the network momentum=>the momentum value (momentum learning only)
new ( [[INPUT VALUES],[OUTPUT VALUES],[INPUT VALUES],[OUTPUT VALUES],..])
These should be comma separated values. They can be applied to the network with ::run or ::learn
These are the intended or target output values. Comma separated These will be used by ::learn
This is a short list of the main methods. For details on all available methods, please see individual pod pages below, and in individual imported modules.
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);
Syntax: $network->init(); Initialises connections between nodes, sets initial weights and loads external components
$network->lesion ({'nodes'=>PROBABILITY,'connections'=>PROBABILITY}) Damages the network. PROBABILITY A value between 0 and 1, denoting the probability of a given node or connection being damaged. Note: this method may be called on a per network, per node or per layer basis using the appropriate object.
$dataset->learn($network) 'Teaches' the network the dataset using the networks defined learning algorithm. Returns sqrError;
$dataset->run($network) Runs the dataset through the network and returns a reference to an array of output patterns.
See the code in ./examples. For any given version of NNFlex, xor.pl will contain the latest functionality.
None. NNFlex should run OK on any version of Perl 5 >.
Phil Brierley, for his excellent free java code, that solved my backprop problem Dr Martin Le Voi, for help with concepts of NN in the early stages Dr David Plaut, for help with the project that this code was originally intended for. Graciliano M.Passos for suggestions & improved code (see SEE ALSO).
AI::NNEasy - Developed by Graciliano M.Passos Shares some common code with NNFlex. Much faster, and more suitable for backprop projects with large datasets.
Lots of things: clean up the perldocs some more write gamma modules write BPTT modules write a perceptron learning module speed it up write a tk gui
v0.11 introduces the lesion method, png support in the draw module and datasets. v0.12 fixes a bug in reinforce.pm & adds a reflector in feedforward->run to make $network->run($dataset) work. v0.13 introduces the momentum learning algorithm and fixes a bug that allowed training to proceed even if the node activation function module can't be loaded v0.14 fixes momentum and backprop so they are no longer nailed to tanh hidden units only. v0.15 fixes a bug in feedforward, and reduces the debug overhead v0.16 changes some underlying addressing of weights, to simplify and speed
Copyright (c) 2004-2005 Charles Colbourn. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
charlesc@nnflex.g0n.net
To install AI::NNFlex, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AI::NNFlex
CPAN shell
perl -MCPAN -e shell install AI::NNFlex
For more information on module installation, please visit the detailed CPAN module installation guide.