5.6.6Machine Learning (Aerospace Applications)

Neural network fundamentals — neuron, activation functions (ReLU, sigmoid, tanh)

2,361 words11 min readdifficulty · medium6 backlinks

The Artificial Neuron

WHY each component?

  • Weights wiw_i: Learning means adjusting these. High weight = "this input matters a lot."
  • Bias bb: Without it, output is zero when all inputs are zero. Bias lets the neuron activate even with no input—think of it as the neuron's "resting potential."
  • Activation ff: Converts the linear combo into a non-linear output. This is crucial—multiple linear functions compose to just another linear function, which can't learn XOR or any complex pattern.
Figure — Neural network fundamentals — neuron, activation functions (ReLU, sigmoid, tanh)

Activation Functions

1. ReLU (Rectified Linear Unit)

WHY ReLU?

  • Computationally cheap: Just a max operation, no exponentials.
  • Solves vanishing gradient: Gradient is1 for z>0z > 0, so backprop signals don't shrink.
  • Sparse activation: Negative inputs output zero—network learns to "switch off" irrelevant neurons.

WHEN to use: Default choice for hidden layers in deep networks (image recognition, control systems).

2. Sigmoid

Properties:

  • Range: (0,1)(0, 1) — naturally interprets as probability.
  • Smooth: Differentiable everywhere.
  • Saturates: For z>5|z| > 5, gradient 0\approx 0 (vanishing gradient problem).

WHEN to use: Binary classification output layer (e.g., "Is this sensor reading anomalous?").

3. Tanh (Hyperbolic Tangent)

Properties:

  • Range: (1,1)(-1, 1) — zero-centered (unlike sigmoid).
  • Stronger gradients near zero than sigmoid.
  • Still saturates at extremes.

WHEN to use: Hidden layers when you want zero-centered activations (helps with convergence), or outputs representing signed quantities (e.g., control surface deflection: -1 = full down, +1 = full up).

Comparison Table

Function Range Zero-Centered? Gradient Issues Best For
ReLU [0,)[0, \infty) No Dead neurons (if z<0z < 0 always) Hidden layers, deep networks
Sigmoid (0,1)(0, 1) No Vanishing gradient Binary output layer
Tanh (1,1)(-1, 1) Yes Vanishing gradient Hidden layers (better than sigmoid), signed outputs
Recall Explain to a 12-Year-Old

Imagine you're building a robot pilot. It needs to decide: "Should I pull the control stick up or push it down?"

The robot's brain is made of tiny decision-makers called neurons. Each neuron looks at sensor readings (airspeed, altitude), multiplies each by a number called a weight (like saying "airspeed is 3× more important than altitude"), adds them up, then adds a bias (a starting nudge).

But here's the trick: if we just add and multiply, the robot can only learn straight-line rules. Real flying is curvy and complex! So we use an activation function—a magic math rule that bends the straight line into curves.

  • ReLU is like a door: negative numbers become zero (door closed), positive numbers stay (door open). Fast and simple.
  • Sigmoid squishes everything between 0 and 1, like a confidence meter: "I'm 90% sure this is an emergency."
  • Tanh squishes between -1 and +1, perfect for "push stick forward (-1) or pull back (+1)."

Without these bending functions, the robot brain would be dumb—just fancy addition. With them, it learns to fly through storms, dodge obstacles, anything!

Connections


#flashcards/coding

What are the three components of an artificial neuron's computation? :: Weighted sum of inputs (wixi\sum w_i x_i), bias (bb), and activation function (ff).

Why do neural networks need activation functions?
Without non-linearity, stacking layers colapses to a single linear transformation (y=Ax+by = Ax + b), incapable of learning complex patterns like XOR or curved decision boundaries.
What is the formula for ReLU?
f(z)=max(0,z)f(z) = \max(0, z). Output is zz if positive, 00 if negative.
What is the derivative of ReLU?
f(z)=1f'(z) = 1 if z>0z > 0, else 00. (Undefined at z=0z=0, but treated as 0 or 1 in practice.)
What problem does ReLU solve compared to sigmoid?
Vanishing gradient problem. ReLU's gradient is 1 for positive inputs, preventing gradient shrinkage in deep networks.
What is the sigmoid function formula?
σ(z)=11+ez\sigma(z) = \frac{1}{1 + e^{-z}}.
What is the range of sigmoid?
(0,1)(0, 1)—naturally interprets as probability.
Derive the derivative of sigmoid.
σ(z)=σ(z)(1σ(z))\sigma'(z) = \sigma(z)(1 - \sigma(z)). Proof: apply chain rule to 11+ez\frac{1}{1+e^{-z}}, factor into σ(z)(1σ(z))\sigma(z) \cdot (1 - \sigma(z)).
What is the tanh function formula?
tanh(z)=ezezez+ez\tanh(z) = \frac{e^z - e^{-z}}{e^z + e^{-z}} or equivalently 2σ(2z)12\sigma(2z) - 1.
What is the range of tanh?
(1,1)(-1, 1)—zero-centered, useful for signed outputs.

What is the derivative of tanh? :: tanh(z)=1tanh2(z)\tanh'(z) = 1 - \tanh^2(z).

When should you use ReLU?
Default for hidden layers in deep networks (fast, avoids vanishing gradient).
When should you use sigmoid?
Binary classification output layer where you need probabilities in [0,1][0, 1].
When should you use tanh?
Hidden layers for zero-centered activations, or outputs representing signed quantities (e.g., control deflections).
What is the "dead ReLU" problem?
A neuron's weighted sum is always negative, so output is always 0. Gradient is 0, weights never update—neuron is permanently inactive.
How do you fix dead ReLU neurons?
Use Leaky ReLU (f(z)=max(0.01z,z)f(z) = \max(0.01z, z)), proper weight initialization (He), or lower learning rate.
Why is sigmoid bad for hidden layers in deep networks?
Vanishing gradient: σ(z)0.25\sigma'(z) \leq 0.25, so gradients multiply to near-zero across many layers, stopping learning.
What is the role of bias bb in a neuron?
Shifts the activation threshold, allowing the neuron to activate even when inputs are zero.
How does ReLU introduce non-linearity if it looks linear for z>0z > 0?
The "kink" at z=0z=0 is the non-linearity. The function is not differentiable everywhere, breaking the linear composition property.

Concept Map

weighted by

scale inputs

shifts threshold

passed through

produces

adds

prevents

enables learning

option

option

option

solves

applied to

Inputs xi

Weighted sum z

Weights wi

Bias b

Activation f z

Output y

Non-linearity

Linear collapse

Complex patterns

ReLU max 0 z

Sigmoid

Tanh

Vanishing gradient

Aerospace tasks

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Neural network ki basic building block hai neuron. Isko samjho biological brain cell ki tarah—inputs lete hai, unhe weights se multiply karte hai (importance decide karne ke liye), sab add karte hai, fir ek bias add karte hai (baseline adjustment), aur finally ek activation function se pass karte hai jo non-linearity lata hai. Ye non-linearity bahut zaroori hai, warna kitne bhi layers stack karo, bas ek fancy linear equation banega—complex patterns nahi seekh payega.

Aerospace mein neural networks ka use hota hai flight control, trajectory prediction, sensor fusion, aur anomaly detection mein. Teen main activation functions hain: ReLU (Rectified Linear Unit), jo negative values ko zero kar deta hai aur positive ko waise hi chodta hai—fast aur vanishing gradient problem solve karta hai, isliye deep networks mein default choice hai. Sigmoid output ko 0 se 1 ke bech squash karta hai, perfect for binary classification (jaise "sensor faulty hai ya nahi?"). Tanh -1 se +1 range deta hai, zero-centered, acha for control outputs jahan positive aur negative dono directions chahiye (jaise elevator up/down deflection).

Common mistake: sigmoid ko hidden layers mein use karna deep networks mein—gradient vanish ho jata hai because sigmoid ka derivative maximum 0.25 hai, toh 10 layers mein multiply karo toh gradient practically zero ho jaata hai. ReLU iska solution hai kyunki uska gradient 1 hai active neurons ke liye.Ek aur problem hai dead ReLU: agar neuron ka weighted sum hamesha negative ho, toh output hamesha 0, gradient0, weights kabhi update nahi—neuron permanently inactive. Fix: Leaky ReLU use karo ya proper initialization (He initialization) karo.

Activation functions neural networks ko power dete hain complex, non-linear patterns seekhne ki—jaise curved flight envelopes, image features, ya XOR logic gates. Bina inke, network sirf straight lines draw kar sakta hai, aur real-world problems rarely linear hote hain!

Go deeper — visual, from zero

Test yourself — Machine Learning (Aerospace Applications)

Connections