42. Activation Functions, Loss, and Gradient Descent (Plain English)
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
- ReLU: negatives become 0; positives pass.
- Sigmoid: squishes any number into (0, 1).
- 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)?
Ravindra Bagale's Tip – मराठी
Hidden layers साठी ReLU हा default choice म्हणून वापरा. Output layer साठी activation problem type बघून निवडा: उत्तर साधा number आहे की probability (जिथे sigmoid सहसा वापरतात)?
Ravindra Bagale's Tip – हिंदी
Hidden layers के लिए ReLU को default choice की तरह इस्तेमाल करो. Output layer के लिए activation problem type देखकर चुनो: जवाब सादा number है या probability (जहाँ sigmoid आमतौर पर इस्तेमाल होता है)?