C.W.K.
Stream
Lesson 06 of 06 · published

From Linear Regression to Deep Learning

~6 min · deep-learning, neural-networks, wrap-up

Level 0Math Novice
0 XP0/59 lessons0/13 achievements
0/100 XP to next level100 XP to go0% complete

The Same Loop, Many Times Over

You've seen the loop:

  1. Define a parametric model (linear regression: ).
  2. Pick a loss function (MSE for regression).
  3. Optimize parameters via gradient descent.
  4. Hold out validation/test data to detect overfitting.

Now stack it. A neural network is just many linear regressions composed together with non-linear activations between them. Each layer is followed by something like ReLU or sigmoid. The final layer is a regression (or classification) head. You optimize all the W's and b's at once via backprop (next track).

The Conceptual Continuity

Linear regressionDeep learning
2 parameters (w, b)millions or billions of parameters
Closed-form solutionGradient descent (no closed form)
1 lineStacked transformations
MSE lossMSE / cross-entropy / etc
Overfitting controlled by data + simple modelOverfitting controlled by data + dropout + weight decay + early stopping

Same chassis, more horsepower.

Track Reward

You've learned the universal learning loop: parametric model + loss + optimizer + held-out evaluation. Linear regression is the seed. Every neural network is the same idea on steroids. The next two tracks (Calculus and Backprop) give you the mechanics that make this loop work for huge models.

Code

A neural network is just stacked regressions·python
import torch
import torch.nn as nn

# A 2-layer neural network — stacked linear regressions
class TinyNet(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc1 = nn.Linear(10, 32)        # linear regression #1
        self.fc2 = nn.Linear(32, 1)         # linear regression #2

    def forward(self, x):
        x = torch.relu(self.fc1(x))         # non-linearity in between
        return self.fc2(x)

# Two linear regressions + one ReLU = neural network.

External links

Exercise

Compare the parameter count of (a) linear regression on 10 features, (b) a 2-layer net (10 → 32 → 1). How many parameters in each? Why does the deeper one have more?
Hint
(a) 10 weights + 1 bias = 11. (b) (10×32 + 32) + (32×1 + 1) = 352 + 33 = 385. The non-linearity earns the extra parameters by letting the model curve.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.