PIXELBANKv9.1.0
Menu

Implement the ReLU activation function, a crucial component in Neural Networks. This function is used to introduce non-linearity in the model, enabling it to learn complex relationships between inputs and outputs.

The ReLU function, or Rectified Linear Unit, is defined as max(0,x)max(0, x), where xx is the input to the function. This function is widely used in Deep Learning due to its simplicity and computational efficiency.

  1. The input xx is passed through the function.
  2. The function returns 00 if xx is negative, and xx if xx is positive.
ReLU(x)=max⁡(0,x)\text{ReLU}(x) = \max(0, x)

This technique is widely used in image classification tasks.

Example:

Input:
relu([-2, -1, 0, 1, 2])
Output:
[0, 0, 0, 1, 2]
Reasoning:
  • Apply ReLU element-wise, using ReLU(x)=max⁡(0,x)\text{ReLU}(x) = \max(0, x) for each input.
  • For the negatives: ReLU(−2)=0\text{ReLU}(-2) = 0, ReLU(−1)=0\text{ReLU}(-1) = 0.
  • For zero and positives: ReLU(0)=0\text{ReLU}(0) = 0, ReLU(1)=1\text{ReLU}(1) = 1, ReLU(2)=2\text{ReLU}(2) = 2.
  • Collecting these results gives the output array: [0, 0, 0, 1, 2].

Constraints:

  • Apply element-wise to input list
solution.py

Test Results

0/0
Run code to see test results.
ReLU Activation - Easy | PixelBank