#98 · Deep Learning · Easy
Implement the PReLU (Parametric Rectified Linear Unit) activation function. PReLU generalizes ReLU by learning the slope for negative inputs: f(x) = x if x > 0, else f(x) = alpha * x, where alpha is a learnable parameter.
f(x) = x
x > 0
f(x) = alpha * x
import numpy as np def prelu(x: np.ndarray, alpha: float = 0.25) -> np.ndarray: return np.where(x > 0, x, alpha * x)
alpha * x