Class: DNN::Activations::LeakyReLU
Instance Attribute Summary collapse
#input_shape, #name
Class Method Summary
collapse
Instance Method Summary
collapse
#build, #built?, #call, call, #output_shape
Constructor Details
#initialize(alpha = 0.3) ⇒ LeakyReLU
Returns a new instance of LeakyReLU.
84
85
86
87
|
# File 'lib/dnn/core/activations.rb', line 84
def initialize(alpha = 0.3)
super()
@alpha = alpha
end
|
Instance Attribute Details
#alpha ⇒ Object
Returns the value of attribute alpha.
77
78
79
|
# File 'lib/dnn/core/activations.rb', line 77
def alpha
@alpha
end
|
Class Method Details
.from_hash(hash) ⇒ Object
79
80
81
|
# File 'lib/dnn/core/activations.rb', line 79
def self.from_hash(hash)
self.new(hash[:alpha])
end
|
Instance Method Details
#backward(dy) ⇒ Object
96
97
98
99
100
|
# File 'lib/dnn/core/activations.rb', line 96
def backward(dy)
dx = Xumo::SFloat.ones(@x.shape)
dx[@x <= 0] = @alpha
dy * dx
end
|
#forward(x) ⇒ Object
89
90
91
92
93
94
|
# File 'lib/dnn/core/activations.rb', line 89
def forward(x)
@x = x
a = Xumo::SFloat.ones(x.shape)
a[x <= 0] = @alpha
x * a
end
|
#to_hash ⇒ Object
102
103
104
|
# File 'lib/dnn/core/activations.rb', line 102
def to_hash
super(alpha: @alpha)
end
|