class DNN::Layers::Lasso

Attributes

l1_lambda[RW]

Public Class Methods

new(l1_lambda = 0.01) click to toggle source

@param [Float] l1_lambda L1 regularizer coefficient.

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

Public Instance Methods

backward_node(dy) click to toggle source
# File lib/dnn/core/layers/basic_layers.rb, line 374
def backward_node(dy)
  dx = Xumo::SFloat.ones(*@x.shape)
  dx[@x < 0] = -1
  @l1_lambda * dx
end
forward_node(x) click to toggle source
# File lib/dnn/core/layers/basic_layers.rb, line 369
def forward_node(x)
  @x = x
  @l1_lambda * x.abs.sum
end
load_hash(hash) click to toggle source
# File lib/dnn/core/layers/basic_layers.rb, line 384
def load_hash(hash)
  initialize(hash[:l1_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 380
def to_hash
  super(l1_lambda: @l1_lambda)
end