Ravindra BagaleCourses & study guides मराठी Track your progress

42. Activation Functions, Loss, and Gradient Descent (Plain English)

Data Science

42.1 Activation Functions Simply

Why. Without an activation, stacked layers collapse into one big linear formula. Activations add the bends that let nets learn curves.

What. Common starters: ReLU (max(0, z)) for hidden layers; sigmoid or softmax often at the end for probabilities.

How.

Try three activations on paper

  1. ReLU: negatives become 0; positives pass.
  2. Sigmoid: squishes any number into (0, 1).
  3. Softmax (multi-class later): turns a vector into probabilities that sum to 1.
import math

def relu(z): return max(0.0, z)
def sigmoid(z): return 1 / (1 + math.exp(-z))

for z in (-2, 0, 2):
 print(z, "ReLU", relu(z), "sigmoid", round(sigmoid(z), 3))

Ravindra Bagale's Tip

Use ReLU as your default choice for hidden layers. For the output layer, choose the activation by the problem type: is the answer a plain number, or a probability (where sigmoid is common)?