Class: TNN::FeedForwardNeuralNetwork::Node
- Inherits:
-
Object
- Object
- TNN::FeedForwardNeuralNetwork::Node
- Defined in:
- lib/t_nn/feedforward_neural_network.rb
Instance Attribute Summary collapse
-
#active_function ⇒ Object
Returns the value of attribute active_function.
-
#id ⇒ Object
Returns the value of attribute id.
-
#threshold ⇒ Object
Returns the value of attribute threshold.
-
#w ⇒ Object
Returns the value of attribute w.
Instance Method Summary collapse
-
#initialize(w = 0.0, active_function = "sig", threshold = 0.0) ⇒ Node
constructor
A new instance of Node.
-
#input(w) ⇒ Object
it can use input fase.
- #set_id(id) ⇒ Object
- #sigmoid_fun(x, a = 1) ⇒ Object
- #update_w(input) ⇒ Object
Constructor Details
#initialize(w = 0.0, active_function = "sig", threshold = 0.0) ⇒ Node
Returns a new instance of Node.
162 163 164 165 166 |
# File 'lib/t_nn/feedforward_neural_network.rb', line 162 def initialize(w = 0.0, active_function = "sig", threshold = 0.0) @w = w @threshold = threshold @active_function = active_function end |
Instance Attribute Details
#active_function ⇒ Object
Returns the value of attribute active_function.
161 162 163 |
# File 'lib/t_nn/feedforward_neural_network.rb', line 161 def active_function @active_function end |
#id ⇒ Object
Returns the value of attribute id.
161 162 163 |
# File 'lib/t_nn/feedforward_neural_network.rb', line 161 def id @id end |
#threshold ⇒ Object
Returns the value of attribute threshold.
161 162 163 |
# File 'lib/t_nn/feedforward_neural_network.rb', line 161 def threshold @threshold end |
#w ⇒ Object
Returns the value of attribute w.
161 162 163 |
# File 'lib/t_nn/feedforward_neural_network.rb', line 161 def w @w end |
Instance Method Details
#input(w) ⇒ Object
it can use input fase
173 174 175 |
# File 'lib/t_nn/feedforward_neural_network.rb', line 173 def input(w) @w = w end |
#set_id(id) ⇒ Object
168 169 170 |
# File 'lib/t_nn/feedforward_neural_network.rb', line 168 def set_id(id) @id = id end |
#sigmoid_fun(x, a = 1) ⇒ Object
182 183 184 |
# File 'lib/t_nn/feedforward_neural_network.rb', line 182 def sigmoid_fun(x, a=1) return (1.0/(1.0+Math.exp(-1.0 * a * x))) end |
#update_w(input) ⇒ Object
177 178 179 180 |
# File 'lib/t_nn/feedforward_neural_network.rb', line 177 def update_w(input) # update by sigmoid @w = sigmoid_fun(input) end |