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.
- Type / level
- study-note · beginner
- Tools
- Python, NumPy, PyTorch, Matplotlib
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
Height and wingspan scales affect gradient magnitudes. Mean subtraction and standard-deviation scaling put both inputs on comparable scales. The figures are archived notebook outputs from that exercise.







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.
Previous and next
Sources used
- Machine Learning Basics and Linear Regression — course-pdf; regression and loss functions
- Gradient Descent — course-pdf; autodiff and parameter updates