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