MCPcopy
hub / github.com/ddbourgin/numpy-ml / fn

Method fn

numpy_ml/neural_nets/activations/activations.py:169–181  ·  view source on GitHub ↗

r""" Evaluate the leaky ReLU function on the elements of input `z`. .. math:: \text{LeakyReLU}(z_i) &= z_i \ \ \ \ &&\text{if } z_i > 0 \\ &= \alpha z_i \ \ \ \ &&\text{otherwise}

(self, z)

Source from the content-addressed store, hash-verified

167 return "Leaky ReLU(alpha={})".format(self.alpha)
168
169 def fn(self, z):
170 r"""
171 Evaluate the leaky ReLU function on the elements of input `z`.
172
173 .. math::
174
175 \text{LeakyReLU}(z_i)
176 &= z_i \ \ \ \ &&\text{if } z_i > 0 \\
177 &= \alpha z_i \ \ \ \ &&\text{otherwise}
178 """
179 _z = z.copy()
180 _z[z < 0] = _z[z < 0] * self.alpha
181 return _z
182
183 def grad(self, x):
184 r"""

Callers 1

Calls 1

copyMethod · 0.45

Tested by 1