TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
TorchedUp
LearnBetaProblemsSystem DesignSoonPremium
←

3. ReLU

Easy

Implement ReLU (Rectified Linear Unit).

Signature: def relu(x: np.ndarray) -> np.ndarray

Math

ReLU(x)=max(0,x)

Asked at

Python 30/10 runs today

Output

Anything you print() in your code will show up here after you click Run.

Test Results

○mixed values
○all negative
○all positive🔒 Premium
○output is non-negative
○idempotent: relu(relu(x)) == relu(x)
○preserves argmax for positive inputs
○batched 3D (B,T,C)🔒 Premium