Class: DNN::Regularizers::L1L2
- Inherits:
-
Regularizer
- Object
- Regularizer
- DNN::Regularizers::L1L2
- Defined in:
- lib/dnn/core/regularizers.rb
Instance Attribute Summary
Attributes inherited from Regularizer
Instance Method Summary collapse
- #forward(x) ⇒ Object
-
#initialize(l1_lambda = 0.01, l2_lambda = 0.01) ⇒ L1L2
constructor
A new instance of L1L2.
- #l1_lambda ⇒ Object
- #l1_lambda=(lam) ⇒ Object
- #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
93 94 95 |
# File 'lib/dnn/core/regularizers.rb', line 93 def forward(x) x + @l1.(@param) + @l2.(@param) end |
#l1_lambda ⇒ Object
97 98 99 |
# File 'lib/dnn/core/regularizers.rb', line 97 def l1_lambda @l1.l1_lambda end |
#l1_lambda=(lam) ⇒ Object
101 102 103 |
# File 'lib/dnn/core/regularizers.rb', line 101 def l1_lambda=(lam) @l1.l1_lambda = lam end |
#l2_lambda ⇒ Object
105 106 107 |
# File 'lib/dnn/core/regularizers.rb', line 105 def l2_lambda @l2.l2_lambda end |
#l2_lambda=(lam) ⇒ Object
109 110 111 |
# File 'lib/dnn/core/regularizers.rb', line 109 def l2_lambda=(lam) @l2.l2_lambda = lam end |
#load_hash(hash) ⇒ Object
117 118 119 |
# File 'lib/dnn/core/regularizers.rb', line 117 def load_hash(hash) initialize(hash[:l1_lambda], hash[:l2_lambda]) end |
#to_hash ⇒ Object
113 114 115 |
# File 'lib/dnn/core/regularizers.rb', line 113 def to_hash super(l1_lambda: l1_lambda, l2_lambda: l2_lambda) end |