class DNN::Layers::Ridge

Attributes

l2_lambda[RW]

Public Class Methods

new(l2_lambda = 0.01) click to toggle source

@param [Float] l2_lambda L2 regularizer coefficient.

Calls superclass method DNN::Layers::Layer::new
# File lib/dnn/core/layers/basic_layers.rb, line 395
def initialize(l2_lambda = 0.01)
  super()
  @l2_lambda = l2_lambda
end

Public Instance Methods

backward_node(dy) click to toggle source
# File lib/dnn/core/layers/basic_layers.rb, line 405
def backward_node(dy)
  @l2_lambda * @x
end
forward_node(x) click to toggle source
# File lib/dnn/core/layers/basic_layers.rb, line 400
def forward_node(x)
  @x = x
  0.5 * @l2_lambda * (x**2).sum
end
load_hash(hash) click to toggle source
# File lib/dnn/core/layers/basic_layers.rb, line 413
def load_hash(hash)
  initialize(hash[:l2_lambda])
end
to_hash() click to toggle source
Calls superclass method DNN::Layers::Layer#to_hash
# File lib/dnn/core/layers/basic_layers.rb, line 409
def to_hash
  super(l2_lambda: @l2_lambda)
end