class DNN::Regularizers::L2

Public Class Methods

new(l2_lambda = 0.01) click to toggle source

@param [Float] l2_lambda L2 regularizer coefficient.

# File lib/dnn/core/regularizers.rb, line 60
def initialize(l2_lambda = 0.01)
  @l2 = Layers::Ridge.new(l2_lambda)
end

Public Instance Methods

forward(x) click to toggle source
# File lib/dnn/core/regularizers.rb, line 64
def forward(x)
  x + @l2.(@param)
end
l2_lambda() click to toggle source
# File lib/dnn/core/regularizers.rb, line 68
def l2_lambda
  @l2.l2_lambda
end
l2_lambda=(lam) click to toggle source
# File lib/dnn/core/regularizers.rb, line 72
def l2_lambda=(lam)
  @l2.l2_lambda = lam
end
load_hash(hash) click to toggle source
# File lib/dnn/core/regularizers.rb, line 80
def load_hash(hash)
  initialize(hash[:l2_lambda])
end
to_hash() click to toggle source
Calls superclass method DNN::Regularizers::Regularizer#to_hash
# File lib/dnn/core/regularizers.rb, line 76
def to_hash
  super(l2_lambda: l2_lambda)
end