Skip to content

kiwigitops/pytorch-demo

Repository files navigation

pytorch-demo

A guided tour of PyTorch, AI/ML fundamentals, and patterns for working with bigger-than-memory data. Each numbered folder is a self-contained lesson with one runnable script and a README that explains the concept.

How to use this repo

  1. Install Python 3.10+ and create a virtual environment.
  2. pip install -r requirements.txt
  3. Walk the lessons in order. Each script runs on CPU in a few seconds.
  4. Read the lesson's README first, then run the script and tweak the numbers.
python 01_tensors/main.py

Lessons

# Folder What you learn
01 tensors The Tensor — PyTorch's NumPy-on-GPU. Creation, shapes, broadcasting, devices.
02 autograd Automatic differentiation. How .backward() and requires_grad power every model.
03 linear_regression A full training loop from scratch on synthetic data. The "hello world" of ML.
04 logistic_regression Binary classification, sigmoid, BCE loss, decision boundaries.
05 mlp Multilayer perceptron with nn.Module. Hidden layers, activations, generalization.
06 cnn A convolutional network for images. Conv, pooling, feature maps.
07 dataset_dataloader Dataset, DataLoader, batching, shuffling, transforms.
08 training_loop A reusable train/val loop with metrics, early stopping, and checkpoints.
09 rnn_sequence LSTMs on a synthetic sequence task. Hidden state, BPTT.
10 transformer A tiny self-attention model. The block diagram behind GPT/BERT, in <100 lines.
11 big_data Streaming with IterableDataset for data that doesn't fit in RAM.

What's an "AI/ML" model, really?

Three pieces, repeated:

  1. A model — a function f(x; θ) with learnable parameters θ (a matrix multiply, a stack of layers, etc.).
  2. A loss — a number that says how wrong f(x; θ) is on training data.
  3. An optimizer — gradient descent, which nudges θ to make the loss smaller.

Every lesson is a variation on those three pieces. Once you see them, the rest is engineering.

Recommended reading after this repo

  • The PyTorch 60-minute blitz
  • Andrej Karpathy's "Neural Networks: Zero to Hero" videos
  • The d2l.ai book (free)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages