Leaky ReLU
2026/3/9小于 1 分钟
Leaky ReLU
题面
Implement a program that performs the leaky ReLU activation function on a vector of floating-point numbers. The leaky ReLU function is defined as:
f(𝑥) = { 𝑥 if 𝑥 > 0 ; 𝛼𝑥 if 𝑥 ≤ 0 }, where 𝛼 is a small positive constant (0.01 in this problem).
Implementation Requirements
- External libraries are not permitted
- The solve function signature must remain unchanged
- The final result must be stored in vector output
- Use 𝛼 = 0.01 as the leaky coefficient
Examples
Example 1:
Input: x = [1.0, -2.0, 3.0, -4.0]
Output: y = [1.0, -0.02, 3.0, -0.04]Example 2:
Input: x = [-1.5, 0.0, 2.5, -3.0]
Output: y = [-0.015, 0.0, 2.5, -0.03]Constraints
- 1 ≤ N ≤ 100,000,000
- -1000.0 ≤ input[i] ≤ 1000.0
- Performance is measured with N = 50,000,000