Class: DNN::Regularizers::L2
- Inherits:
-
Regularizer
- Object
- Regularizer
- DNN::Regularizers::L2
- Defined in:
- lib/dnn/core/regularizers.rb
Instance Attribute Summary
Attributes inherited from Regularizer
Instance Method Summary collapse
- #forward(x) ⇒ Object
-
#initialize(l2_lambda = 0.01) ⇒ L2
constructor
A new instance of L2.
- #l2_lambda ⇒ Object
- #l2_lambda=(lam) ⇒ Object
- #load_hash(hash) ⇒ Object
- #to_hash ⇒ Object
Methods inherited from Regularizer
Constructor Details
Instance Method Details
#forward(x) ⇒ Object
64 65 66 |
# File 'lib/dnn/core/regularizers.rb', line 64 def forward(x) x + @l2.(@param) end |
#l2_lambda ⇒ Object
68 69 70 |
# File 'lib/dnn/core/regularizers.rb', line 68 def l2_lambda @l2.l2_lambda end |
#l2_lambda=(lam) ⇒ Object
72 73 74 |
# File 'lib/dnn/core/regularizers.rb', line 72 def l2_lambda=(lam) @l2.l2_lambda = lam end |
#load_hash(hash) ⇒ Object
80 81 82 |
# File 'lib/dnn/core/regularizers.rb', line 80 def load_hash(hash) initialize(hash[:l2_lambda]) end |
#to_hash ⇒ Object
76 77 78 |
# File 'lib/dnn/core/regularizers.rb', line 76 def to_hash super(l2_lambda: l2_lambda) end |