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)
| 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""" |