class RubyNEAT::Cli::Generator::Neater
Attributes
bias[RW]
description[RW]
inputs[RW]
outputs[RW]
Public Instance Methods
create_neater_file()
click to toggle source
# File lib/rubyneat/cli/generate.rb, line 68 def create_neater_file setup_neuron_parameters @description ||= "#{name.camel_case} Neater" template 'neater', "neater/#{name.snake}_neat.rb" end
Private Instance Methods
setup_neuron_parameters()
click to toggle source
We need to create the Input Neurons (including the bias neuron), the Output Neurons, and the Hidden neurons. attr:name attr:n1:t1,n2:t2,…
# File lib/rubyneat/cli/generate.rb, line 79 def setup_neuron_parameters params = { inputs: {in1: 'input', in2: 'input'}, outputs: {out: 'tanh'}, hidden: {tanh: nil}, bias: 'bias', description: 'Neater scaffold' }.merge(nparams.inject({}) { |memo, (k,v)| memo[k.to_sym] = Hash[v.split(',').map{|q| q.split(':') }]. inject({}) {|mmemo, (kk, vv)| mmemo[kk.to_sym] = vv; mmemo} memo }) puts params params.each do |attr, o| instance_variable_set("@#{attr}", case attr when :inputs, :outputs o.inject({}){|memo, (ky, vl)| memo[ky] = unless vl.nil? vl.camel_case else case attr when :inputs; 'Input' when :outputs; 'Output' end end + 'Neuron' memo } when :bias unless o.nil? o.camel_case else 'Bias' end + 'Neuron' when :hidden o.map{|hk, ignore| hk.to_s.camel_case + 'Neuron' } when :description; o.keys.first else o end) puts attr end end