Browse and solve 1,200+ machine learning coding challenges on Deep-ML. Filter by difficulty (beginner, intermediate, advanced) and category (linear algebra, machine learning, deep learning, NLP, computer vision). Write Python solutions in the browser and get instant feedback against test cases.
Write a Python function relu that implements the Rectified Linear Unit (ReLU) activation function. The function should take a single float as input and return the value after applying the ReLU function. The ReLU function returns the input if it's greater than 0, otherwise, it returns 0.
print(relu(0.0)) print(relu(1.0)) print(relu(-1.0))
0.0 1.0 0.0
The ReLU function is applied to the input values 0.0, 1.0, and -1.0. The output is 0 for negative values and the input value for non-negative values.