Instantly share code, notes, and snippets.

Embed
What would you like to do?
Why doesn't my FANN work? :(
require 'ruby-fann'
input_data = (0..20000).collect do |i|
[i * 0.0001]
end
output_data = input_data.collect do |i|
[Math.sin(i.first)]
end
train = RubyFann::TrainData.new(:inputs => input_data, :desired_outputs => output_data)
fann = RubyFann::Standard.new(:num_inputs => 1, :hidden_neurons => [9, 9, 9], :num_outputs => 1)
fann.train_on_data(train, 1000, 10, 0.1) # 1000 max_epochs, 10 errors between reports and 0.1 desired MSE (mean-squared-error)
(0..20).each do |i|
r = i * 0.1
puts "Want: #{Math.sin(r)}, got: #{fann.run([r])}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment