Class: TNN::FeedForwardNeuralNetwork::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/t_nn/feedforward_neural_network.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(w = 0.0, active_function = "sig", threshold = 0.0) ⇒ Node

Returns a new instance of Node.



172
173
174
175
176
# File 'lib/t_nn/feedforward_neural_network.rb', line 172

def initialize(w = 0.0, active_function = "sig", threshold = 0.0)
  @w = w 
  @threshold = threshold 
  @active_function = active_function
end

Instance Attribute Details

#active_functionObject

Returns the value of attribute active_function.



171
172
173
# File 'lib/t_nn/feedforward_neural_network.rb', line 171

def active_function
  @active_function
end

#idObject

Returns the value of attribute id.



171
172
173
# File 'lib/t_nn/feedforward_neural_network.rb', line 171

def id
  @id
end

#thresholdObject

Returns the value of attribute threshold.



171
172
173
# File 'lib/t_nn/feedforward_neural_network.rb', line 171

def threshold
  @threshold
end

#wObject

Returns the value of attribute w.



171
172
173
# File 'lib/t_nn/feedforward_neural_network.rb', line 171

def w
  @w
end

Instance Method Details

#input(w) ⇒ Object

it can use input fase



183
184
185
# File 'lib/t_nn/feedforward_neural_network.rb', line 183

def input(w)
  @w = w
end

#set_id(id) ⇒ Object



178
179
180
# File 'lib/t_nn/feedforward_neural_network.rb', line 178

def set_id(id) 
  @id = id
end

#sigmoid_fun(x, a = 1) ⇒ Object



192
193
194
# File 'lib/t_nn/feedforward_neural_network.rb', line 192

def sigmoid_fun(x, a=1)
  return (1.0/(1.0+Math.exp(-1.0 * a * x)))
end

#update_w(input) ⇒ Object



187
188
189
190
# File 'lib/t_nn/feedforward_neural_network.rb', line 187

def update_w(input)
  # update by sigmoid
  @w = sigmoid_fun(input)
end