AI · Deep Learning · Computer Vision · Machine Learning Basics

OUTTA Basic — From Data Exploration to Autodiff and Linear Regression

2026-08-01 · updated 2026-08-01 · Hyeongrok Ryu

I revisited scatter plots, loss surfaces, gradient descent, and normalization using the linear-regression outputs retained in my notebook.

Series
2024 OUTTA AI Bootcamp Basic · 1
Type / level
study-note · beginner
Tools
Python, NumPy, PyTorch, Matplotlib
01Why I plotted first

A checkpoint in the study sequence for this note.

02Reading relationships

A checkpoint in the study sequence for this note.

03Loss surfaces and autodiff

A checkpoint in the study sequence for this note.

04Normalization and convergence

A checkpoint in the study sequence for this note.

A compact concept path generated from this post's table of contents.

Why I plotted first

I began by plotting the inputs instead of memorizing a regression formula. After reading the 39-page regression module, I compared hand length, hand width, height, weight, and wingspan in the NBA draft measurements notebook. I checked the direction of each point cloud and noticed that a categorical axis such as position needs different handling from a continuous input.

Reading relationships

Height and wingspan showed a roughly linear relationship. I first predicted the direction from the scatter alone, then overlaid a line and repeated the plot through a second implementation. Matching axes and units mattered more than making the plot decorative.

I wrote the model as ŷ = mx + b and the mean squared error as

L(m, b) = (1/N) Σᵢ(mxᵢ + b − yᵢ)²

Loss surfaces and autodiff

While reading the 25-page gradient-descent module, I plotted loss against (m) and (b). The phrase “move downhill” initially felt separate from loss.backward(). Marking the current point and update path on the surface connected the gradient to a direction in parameter space.

Normalization and convergence

The scale of height and wingspan also changed the gradient scale. I subtracted the mean and divided by the standard deviation, then studied the same model again. These figures are outputs retained in the notebook from that work; I did not present them as a fresh rerun.

What stored errors taught me

My edited regression notebook retained 30 output objects, 13 figures, and three error outputs. I kept those failures in the study record and checked tensor dtype and shape, requires_grad, and the order of the update and gradient reset. Forgetting zero_grad() causes gradients to accumulate across iterations.

Minimal regression loop

m = torch.zeros((), requires_grad=True)
b = torch.zeros((), requires_grad=True)

for _ in range(50):
    prediction = m * x + b
    loss = ((prediction - y) ** 2).mean()
    loss.backward()
    with torch.no_grad():
        m -= learning_rate * m.grad
        b -= learning_rate * b.grad
        m.grad.zero_()
        b.grad.zero_()

The loop stays short but preserves forward, loss, backward, update, and reset. The next note moves from a line to function approximation and nonlinear spiral classification.

Sources used

  • Machine Learning Basics and Linear Regression — course-pdf; regression and loss functions
  • Gradient Descent — course-pdf; autodiff and parameter updates
Publication first-page preview