ruby - Train neural network with sine function -
i want train neural network sine() function. currently use code , ( cerebrum gem): require 'cerebrum' input = array.new 300.times |i| inputh = hash.new inputh[:input]=[i] sinus = math::sin(i) inputh[:output] = [sinus] input.push(inputh) end network = cerebrum.new network.train(input, { error_threshold: 0.00005, iterations: 40000, log: true, log_period: 1000, learning_rate: 0.3 }) res = array.new 300.times |i| result = network.run([i]) res.push(result[0]) end puts "#{res}" but not work, if run trained network weird output values (instead of getting part of sine curve). so, doing wrong? cerebrum basic , slow nn implementation. there better options in ruby, such ruby-fann gem. most problem network simple. have not specified hidden layers - looks code assigns default hidden layer 3 neurons in case. try like: network = cerebrum.new({ learning_rate: 0.01, momentum: 0.9, hidden_l