Leaky ReLU

EasyMachine LearningMathArray

Description

Given an array of numbers, apply the Leaky ReLU activation: return x for positive inputs and 0.01 * x for non-positive inputs. Round each result to 4 decimal places.

Examples

Input:[1,-1,2,-2]
Output:[1,-0.01,2,-0.02]
Explanation:

Positive values pass through unchanged while negative values are scaled down by a small slope instead of being zeroed out.

Input:[0,5,-5]
Output:[0,5,-0.05]
Explanation:

Positive values pass through unchanged while negative values are scaled down by a small slope instead of being zeroed out.

Input:[-10]
Output:[-0.1]
Explanation:

Positive values pass through unchanged while negative values are scaled down by a small slope instead of being zeroed out.

Constraints

  • 1 ≤ length ≤ 10⁴

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.