Class: DNN::Activations::LeakyReLU
Instance Method Summary collapse
- #backward(dout) ⇒ Object
- #forward(x) ⇒ Object
-
#initialize(alpha = 0.3) ⇒ LeakyReLU
constructor
A new instance of LeakyReLU.
Constructor Details
#initialize(alpha = 0.3) ⇒ LeakyReLU
Returns a new instance of LeakyReLU.
53 54 55 |
# File 'lib/dnn/core/activations.rb', line 53 def initialize(alpha = 0.3) @alpha = alpha end |
Instance Method Details
#backward(dout) ⇒ Object
64 65 66 67 68 |
# File 'lib/dnn/core/activations.rb', line 64 def backward(dout) @x[@x > 0] = 1 @x[@x <= 0] = @alpha dout * @x end |
#forward(x) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/dnn/core/activations.rb', line 57 def forward(x) @x = x.clone a = Numo::SFloat.ones(x.shape) a[x <= 0] = @alpha x * a end |