Class: DNN::Layers::Ridge
Instance Attribute Summary collapse
Attributes inherited from Layer
#input_shape, #output_shape
Instance Method Summary
collapse
Methods included from LayerNode
#forward
Methods inherited from Layer
#<<, #build, #built?, #call, call, #clean, #compute_output_shape, #forward, from_hash
Constructor Details
#initialize(l2_lambda = 0.01) ⇒ Ridge
Returns a new instance of Ridge.
376
377
378
379
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 376
def initialize(l2_lambda = 0.01)
super()
@l2_lambda = l2_lambda
end
|
Instance Attribute Details
#l2_lambda ⇒ Object
Returns the value of attribute l2_lambda.
373
374
375
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 373
def l2_lambda
@l2_lambda
end
|
Instance Method Details
#backward_node(dy) ⇒ Object
386
387
388
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 386
def backward_node(dy)
@l2_lambda * @x
end
|
#forward_node(x) ⇒ Object
381
382
383
384
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 381
def forward_node(x)
@x = x
0.5 * @l2_lambda * (x**2).sum
end
|
#load_hash(hash) ⇒ Object
394
395
396
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 394
def load_hash(hash)
initialize(hash[:l2_lambda])
end
|
#to_hash ⇒ Object
390
391
392
|
# File 'lib/dnn/core/layers/basic_layers.rb', line 390
def to_hash
super(l2_lambda: @l2_lambda)
end
|