ruby-fann

Get Version

0.7.8

Bindings to use FANN (Fast Artificial Neural Network) from within ruby/rails environment.

Documentation

Get your documentation here: Docs

Installing

Requirements:

Unit Tests

ruby-fann Gem has full complement of unit tests that are executed before the gem is deployed/redeployed to RubyForge.

Demonstration of usage

require 'rubygems'
require 'ruby_fann/neural_network'

# Create Training data with 2 each of inputs(array of 3) & desired outputs(array of 1).
training_data = RubyFann::TrainData.new(
  :inputs=>[[0.3, 0.4, 0.5], [0.1, 0.2, 0.3]], 
  :desired_outputs=>[[0.7], [0.8]])

# Create FANN Neural Network to match appropriate training data:
fann = RubyFann::Standard.new(
  :num_inputs=>3, 
  :hidden_neurons=>[2, 8, 4, 3, 4], 
  :num_outputs=>1)

# Training using data created above:
fann.train_on_data(training_data, 1000, 1, 0.1)

# Run with different input data:
outputs = fann.run([0.7, 0.9, 0.2])    

Now implements a callback method

This callback function can be called during training when using train_on_data, train_on_file or cascadetrain_on_data.

It is very useful for doing custom things during training. It is recommended to use this function when implementing custom training procedures, or when visualizing the training in a GUI etc. The args which the callback function takes is the parameters given to the train_on_data, plus an epochs parameter which tells how many epochs the training have taken so far.

The callback method should return an integer, if the callback function returns -1, the training will terminate.

The callback (training_callback) will be automatically called if it is implemented on your subclass as follows:

class MyFann < RubyFann::Standard
  def training_callback(args)
    puts "ARGS: #{args.inspect}" 
    0  
  end
end

Forum

http://groups.google.com/group/ruby_fann

How to submit patches

Read the 8 steps for fixing other people’s code and for section 8b: Submit patch to Google Groups, use the Google Group above.

The trunk repository is svn://rubyforge.org/var/svn/ruby-fann/trunk for anonymous access.

License

This code is free to use under the terms of the MIT license.

Contact

Comments are welcome. Send an email to Steven Miers email via the forum

Steven Miers, 9th April 2008