Front page | perl.ai |
Postings from April 2006
[ANNOUNCE] AI::FANN
Thread Next
From:
Salvador Fandiño
Date:
April 14, 2006 03:51
Subject:
[ANNOUNCE] AI::FANN
Message ID:
20060414105142.32150.qmail@lists.develooper.com
Hi,
I have uploaded the new AI::FANN module to CPAN:
http://search.cpan.org/~salva/AI-FANN/
It is a wrapper for the Fast Artificial Neural Network library
(http://fann.sf.net):
Fast Artificial Neural Network Library is a free open source
neural network library, which implements multilayer artificial
neural networks in C with support for both fully connected and
sparsely connected networks. Cross-platform execution in both
fixed and floating point are supported. It includes a framework
for easy handling of training data sets. It is easy to use,
versatile, well documented, and fast. PHP, C++, .NET, Python,
Delphi, Octave, Ruby, Pure Data and Mathematica bindings are
available. A reference manual accompanies the library with
examples and recommendations on how to use the library. A
graphical user interface is also available for the library.
This is an early release that may contain critical bugs, though
most things seem to be working properly.
The documentation focus on the differences with the C library, and
both versions should be consulted in order to use the module.
Training an ANN to emulate a XOR gate with AI::FANN looks like
that:
use AI::FANN qw(:all);
# create an ANN with 2 inputs, a hidden layer with 3 neurons
# and an output layer with 1 neuron:
my $ann = AI::FANN->new_standard(2, 3, 1);
$ann->hidden_activation_function(FANN_SIGMOID_SYMMETRIC);
$ann->output_activation_function(FANN_SIGMOID_SYMMETRIC);
# create the training data for a XOR operator:
my $xor_train = AI::FANN::TrainData->new( [-1, -1], [-1],
[-1, 1], [1],
[1, -1], [1],
[1, 1], [-1] );
$ann->train_on_data($xor_train, 500000, 1000, 0.001);
$ann->save("xor.ann");
And using the trained ANN:
use AI::FANN;
my $ann = AI::FANN->new_from_file("xor.ann");
for my $a (-1, 1) {
for my $b (-1, 1) {
my $out = $ann->run([$a, $b]);
printf "xor(%f, %f) = %f\n", $a, $b, $out->[0];
}
}
Comments and feedback are very welcome!
Cheers,
- Salva.
Thread Next
-
[ANNOUNCE] AI::FANN
by Salvador Fandiño