ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-ai
perl-ai
[ANNOUNCE] AI::FANN
by Salvador Fandiņo other posts by this author
Apr 14 2006 3:52AM messages near this date
ai::categorize samples | Re: [ANNOUNCE] AI::FANN
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:
Salvador Fandiņo
Ovid
Salvador "Fandiņo

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved