Class: Perceptron::Weight
- Inherits:
-
Object
- Object
- Perceptron::Weight
- Defined in:
- lib/perceptron/weight.rb
Constant Summary collapse
- INITIAL_BIAS =
0
Instance Attribute Summary collapse
-
#vector ⇒ Object
readonly
Returns the value of attribute vector.
Instance Method Summary collapse
- #create(features_number) ⇒ Object
-
#initialize(features_number) ⇒ Weight
constructor
A new instance of Weight.
- #update(values) ⇒ Object
Constructor Details
#initialize(features_number) ⇒ Weight
Returns a new instance of Weight.
8 9 10 11 |
# File 'lib/perceptron/weight.rb', line 8 def initialize(features_number) @values = Array.new(features_number, 0) @vector = vector_init(@values) end |
Instance Attribute Details
#vector ⇒ Object (readonly)
Returns the value of attribute vector.
4 5 6 |
# File 'lib/perceptron/weight.rb', line 4 def vector @vector end |
Instance Method Details
#create(features_number) ⇒ Object
13 14 15 |
# File 'lib/perceptron/weight.rb', line 13 def create(features_number) @weight = Weight.new(features_number) end |
#update(values) ⇒ Object
17 18 19 |
# File 'lib/perceptron/weight.rb', line 17 def update(values) @vector = Vector[*values] end |