class Chainer::Functions::Activation::LeakyReLUGrad

Public Class Methods

new(x, y, slope) click to toggle source
# File lib/chainer/functions/activation/leaky_relu.rb, line 66
def initialize(x, y, slope)
  @x = x
  @y = y
  @slope = slope
end

Public Instance Methods

backward(indexes, grad_outputs) click to toggle source
# File lib/chainer/functions/activation/leaky_relu.rb, line 83
def backward(indexes, grad_outputs)
  LeakyReLUGrad.new(@x, @y, @slope).apply(grad_outputs)
end
forward(inputs) click to toggle source
# File lib/chainer/functions/activation/leaky_relu.rb, line 72
def forward(inputs)
  gy, = inputs
  gy = gy.dup
  if @slope >= 0
    gy[@y < 0] *= @slope
  else
    gy[@x < 0] *= @slope
  end
  [gy]
end