class DNN::Layers::LeakyReLU

Attributes

alpha[R]

Public Class Methods

new(alpha = 0.3) click to toggle source

@param [Float] alpha The slope when the output value is negative.

Calls superclass method
# File lib/dnn/core/layers/activations.rb, line 86
def initialize(alpha = 0.3)
  super()
  @alpha = alpha
end

Public Instance Methods

backward_node(dy) click to toggle source
# File lib/dnn/core/layers/activations.rb, line 98
def backward_node(dy)
  dx = Xumo::SFloat.ones(@x.shape)
  dx[@x <= 0] = @alpha
  dy * dx
end
forward_node(x) click to toggle source
# File lib/dnn/core/layers/activations.rb, line 91
def forward_node(x)
  @x = x
  a = Xumo::SFloat.ones(x.shape)
  a[x <= 0] = @alpha
  x * a
end
load_hash(hash) click to toggle source
# File lib/dnn/core/layers/activations.rb, line 108
def load_hash(hash)
  initialize(hash[:alpha])
end
to_hash() click to toggle source
Calls superclass method
# File lib/dnn/core/layers/activations.rb, line 104
def to_hash
  super(alpha: @alpha)
end