Created
March 11, 2016 08:14
-
-
Save eccyan/0501dc28b6bb65e5e50b to your computer and use it in GitHub Desktop.
FANN テスト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ruby-fann' | |
inputs = 0.step(Math::PI * 2, 0.01).map { |x| [x] } | |
desired_outputs = inputs.map { |i| [Math.sin(i.first)] } | |
train = RubyFann::TrainData.new(inputs: inputs, desired_outputs: desired_outputs) | |
fann = RubyFann::Standard.new(:num_inputs=>1, :hidden_neurons=>[10, 20], :num_outputs=>1) | |
fann.set_activation_function_hidden(:sigmoid_symmetric) | |
fann.set_activation_function_output(:sigmoid_symmetric) | |
fann.train_on_data(train, 2000, 20, 0.001) | |
inputs.map(&:first).map { |i| [i, Math.sin(i), fann.run([i]).first] }.map { |a| a.concat [a[1] - a[2]] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment