Grokbase Groups Perl ai April 2006
FAQ
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.

Search Discussions

  • Ovid at Apr 14, 2006 at 4:26 pm

    --- Salvador Fandi�o wrote:

    Hi,

    I have uploaded the new AI::FANN module to CPAN:

    http://search.cpan.org/~salva/AI-FANN/
    Looks great (from the docs, haven't tested it).

    I think these are a typos:

    FANN::AI->new_standard(@layer_sizes)
    FANN::AI->new_sparse($connection_rate, @layer_sizes)
    FANN::AI->new_shortcut(@layer_sizes)
    FANN::AI->new_from_file($filename)

    Cheers,
    Ovid

    --
    If this message is a response to a question on a mailing list, please send follow up questions to the list.

    Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/
  • Salvador "Fandiño" at Apr 14, 2006 at 5:51 pm

    --- Ovid wrote:

    I think these are a typos:

    FANN::AI->new_standard(@layer_sizes)
    FANN::AI->new_sparse($connection_rate, @layer_sizes)
    FANN::AI->new_shortcut(@layer_sizes)
    FANN::AI->new_from_file($filename)
    oh, yes, thank you for pointing them.

    Cheers,

    - Salva


    __________________________________________________
    Do You Yahoo!?
    Tired of spam? Yahoo! Mail has the best spam protection around
    http://mail.yahoo.com

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupai @
categoriesperl
postedApr 14, '06 at 10:51a
activeApr 14, '06 at 5:51p
posts3
users2
websiteperl.org

2 users in discussion

Salvador "Fandiño": 2 posts Ovid: 1 post

People

Translate

site design / logo © 2021 Grokbase