🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
💼 Servicesℹ️ About✉️ ContactView Pricing Plansfrom $10

Neural Networks: Perceptron to MLP — Full Mathematical Foundation

Module 12: Deep LearningNeural Networks🟢 Free Lesson

Advertisement

Neural Networks: Perceptron to MLP

The Building Block of Deep Learning

Every deep learning model — from CNNs to Transformers — is built from neural networks. Understanding the math behind them is essential.

Deep Learning Architecture Family

Deep Learning Architecture FamilyNeuralNetworkCNNVisionRNNSequentialTransformerNLP/AllGANGenerationDiffusionImagesGNNGraphs

All architectures are built from the same fundamental building blocks


1. The Perceptron (Single Neuron)

Mathematical Model:

Where:

  • = input vector

  • = weight vector (learned parameters)

  • = bias term

  • = activation function

The Perceptron: Single Neuronx₁w₁x₂w₂x₃w₃x₃w₃Σwᵢ¢xᵢ¢ + bσ(z)Activationσ(z)ŷoutputbbias

z = w₁x₁ + w₂x₂ + w₃x₃ + w₃x₃ + b → ŷ = σ(z)


2. Activation Functions

Why Activation Functions?

Without activation, a neural network is just linear regression:

Activation functions introduce non-linearity, allowing the network to learn complex patterns.

Sigmoid, Tanh, ReLU Comparison

Activation Functions ComparisonSigmoidσ(z) = 1/(1+e⁻ˣ)Tanhtanh(z) = (eá¶»-e⁻ˣ)/(eá¶»+e⁻ˣ)ReLUmax(0, z)-4+40Range: (0,1)Range: (-1,1)Range: [0,≡)

Activation Function Formulas

Sigmoid



Output: (0, 1) — good for probabilities

Tanh



Output: (-1, 1) — zero-centered

ReLU



Output: [0, ≡) — most popular in hidden layers

Leaky ReLU and GELU (Modern Alternatives)

Modern Activation FunctionsLeaky ReLUf(z) = max(αz, z), α = 0.01GELU (Transformers)f(z) = z·Φ(z), Φ = Gaussian CDF

3. Multi-Layer Perceptron (MLP)

Multi-Layer Perceptron (MLP) ArchitectureInputLayerHidden 164 neuronsHidden 232 neuronsHidden 316 neuronsOutput1 neuronxxxxxh₁h₁h₁h₁h₁h₁h₂h₂h₂h₂h₂h₃h₃h₃h₃ŷForward Propagation →

4. Forward Propagation (Mathematical)

Layer-by-Layer Computation:

Layer 1:

Layer 2:

General Layer :

Output:


5. Backpropagation (The Chain Rule)

Loss Function (Binary Cross-Entropy):

Gradient for Output Layer:

Gradient for Hidden Layer :

Weight Update:

Backpropagation: Computing GradientsForward Pass (compute predictions)InputxHiddenz₍¹₎, a₍¹₎Hiddenz₍²₎, a₍²₎OutputŷLossL(ŷ, y)Backward Pass (compute gradients)Δ₍³₎ = ŷ - yΔ₍²₎ = W³ᵀΔ³ ⊙ σ'Δ₍¹₎ = W²ᵀΔ² ⊙ σ'∂L/∂W₍¹₎

Weight Update: W := W - α · ∂L/∂W

α = learning rate, ∂L/∂W = gradient from backpropagation


6. Loss Functions

Regression Loss (MSE):

Classification Loss (Cross-Entropy):

Binary:

Multi-class:


7. Weight Initialization

Why Not Initialize All Weights to Zero?

If , all neurons compute the same function → no symmetry breaking → network can't learn.

Xavier/Glorot Initialization (Sigmoid/Tanh):

He Initialization (ReLU):


8. Optimizers

Optimization Algorithms ComparisonVanilla GDSGD (noisy)Adam (fastest convergence)Vanilla GDSGDAdam

Adam Optimizer (Most Popular)

Adam Update Rules:

Defaults: , , ,


Key Takeaways

  1. Perceptron = weighted sum + activation — the basic unit

  2. MLP = multiple perceptrons in layers — universal approximator

  3. Activation functions introduce non-linearity — ReLU is default

  4. Backpropagation = chain rule applied recursively — computes gradients

  5. Adam optimizer is the default choice for most problems

  6. Weight initialization matters — use He init for ReLU

Next: PyTorch Fundamentals

Implement neural networks in PyTorch with autograd, tensors, and GPU support.

Need Expert Data Science Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement