LeakyReLU

class LeakyReLU(negative_slope=0.01, **kwargs)[源代码]

对每个元素应用函数:

LeakyReLU(x)=max(0,x)+negative_slope×min(0,x)

或者

LeakyReLU(x)={x, if x0negative_slope×x, otherwise 

实际案例

import numpy as np
import megengine as mge
import megengine.module as M
data = mge.tensor(np.array([-8, -12, 6, 10]).astype(np.float32))

leakyrelu = M.LeakyReLU(0.01)
output = leakyrelu(data)
print(output.numpy())

输出:

[-0.08 -0.12  6.   10.  ]