Skip to content

Instantly share code, notes, and snippets.

@nmeans
Created May 7, 2013 15:13
Show Gist options
  • Save nmeans/5533387 to your computer and use it in GitHub Desktop.
Save nmeans/5533387 to your computer and use it in GitHub Desktop.
ruby-fann negative/positive demo
input = (-1000...1000).collect{|i| [i]}
output = input.map{|i| i > 0 ? [1,0] : [0,1]}
train = RubyFann::TrainData.new(:inputs => input, :desired_outputs => output)
fann = RubyFann::Standard.new(:num_inputs=>2, :hidden_neurons=>[3,3,3], :num_outputs=>2)
fann.train_on_data(train, 1001, 10, 0.001)
fann.run([-500]) # [0.03544681023290716, 1.0]
fann.run([500]) # [1.0, 0.0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment