Premium problem123. Dense Layer Forward with Leaky ReLU

Easy Locked

Return the (n, h) activation leaky_relu(X @ W + b):

  • X has shape (n, d), weights W have shape (d, h), bias b has shape (h,)
  • leaky_relu(z) = z for z > 0, and alpha * z otherwise

Input

X =
[[ 1. -2.]
 [ 3.  4.]]
W =
[[1. 0.]
 [0. 1.]]
b = [ 0.5 -0.5]
alpha = 0.01

Output

[[ 1.5   -0.025]
 [ 3.5    3.5  ]]

Premium problem

This one's part of Premium. Unlock the full NumPy track plus every other premium problem on the site.

Implement solve(...)