PyTorch Without the Calculus: What It Is and What You Can Ignore

A gentle, math-free introduction to PyTorch for engineers and technical PMs — what it actually is, what you can safely skip, and how to set up Google Colab to run real AI models.

There’s a gap between “I read the announcement about a new AI model” and “I ran it myself and saw what it does.” Closing that gap is what this book is for. You’re a capable engineer (or a technical PM who isn’t scared of a code cell), you don’t have a deep-learning math background, and you don’t want one — you want to take models off the shelf and run them. That’s a completely reasonable goal, and PyTorch is the tool that gets you there.

This first chapter sets expectations: what PyTorch is, what you’re allowed to ignore, and how to get a free GPU running in your browser. Every hands-on chapter comes with a companion notebook you can run as you read:

▶ Open the companion notebook in Colab

Run against: PyTorch 2.2.2 and transformers 4.57.6 on CPU (macOS); where transformers 5.x behaves differently the text says so, from its source.

What PyTorch actually is

PyTorch is the engine that runs most modern AI models. When you read about a new open model — a language model, an image generator, a speech recognizer — the odds are overwhelming that it was built with PyTorch and ships as PyTorch weights. Learn to drive PyTorch and a huge fraction of the AI world opens up.

Under the hood it’s three things:

  • Tensors — multi-dimensional arrays (think NumPy arrays) that can live on a GPU for speed. This is the data structure everything flows through, and it’s the one part you genuinely need to be comfortable with. That’s chapter 2.
  • Autograd — the bookkeeping that lets a model learn by automatically working out how to adjust its numbers. It’s the clever core of training. Here’s the good news: to run an existing model, you never touch it.
  • nn (neural network building blocks) — the layers models are assembled from. We’ll take a look inside one so models stop feeling like black boxes, but you won’t be hand-building architectures.

The useful analogy: PyTorch is like a car. Autograd and the training math are the engine internals. You’re learning to drive — steering, pedals, reading the dashboard — not to rebuild the transmission. Plenty of people drive their whole lives without opening the hood, and they get where they’re going.

What you can safely ignore

Because this trips people up, let me be blunt about what this book deliberately skips:

  • The calculus. Gradients, derivatives, the chain rule, backpropagation — the machinery of how models learn. You can run any pretrained model without it.
  • The training loop. Epochs, loss functions, optimizers. That’s how a model is made; we’re using ones that already exist.
  • The linear algebra proofs. You need to know a tensor has a shape, not how to derive a matrix multiplication.

None of that is forbidden knowledge — it’s just a different goal, and it’s where the Training Models book goes (understanding and fine-tuning models on your own data). This book keeps both hands on the wheel: load a model, feed it input, read the output, repeat with bigger and more interesting models. If you’ve been put off PyTorch by a tutorial that opened with partial derivatives, this is the book that doesn’t.

Your runtime: Google Colab

Running models means running real computation, sometimes on a GPU. You do not need a powerful laptop or a CUDA install — Google Colab gives you a Python notebook with a free GPU, in your browser, with PyTorch already installed. It’s where this whole book lives.

To get set up:

  1. Go to colab.research.google.com and create a new notebook (a Google account is all you need).
  2. For a GPU: Runtime → Change runtime type → Hardware accelerator → GPU. (You don’t need it for the first few chapters; it matters once models get bigger.)
  3. Type Python into a cell and press Shift+Enter to run it.

That’s the entire setup. No terminal, no pip install torch, no driver wrangling.

Your first thirty seconds of PyTorch

Open the companion notebook above and run this — it confirms PyTorch is present and tells you whether a GPU is attached:

import torch

print("PyTorch version:", torch.__version__)
print("GPU available:", torch.cuda.is_available())

Then make your first tensor — an array PyTorch understands and can move to the GPU:

x = torch.tensor([[1.0, 2.0, 3.0],
                  [4.0, 5.0, 6.0]])

print(x.shape)    # torch.Size([2, 3]) — 2 rows, 3 columns
print(x.device)   # cpu (for now)

If that ran, you’re already further than most people who “mean to get into AI.” We’ll spend the next chapter making tensors feel routine, because they’re the one thing you’ll touch constantly.

What “running a model” will look like

To show you where this is heading, here’s the kind of code this book builds toward — a complete, working sentiment classifier using a pretrained model:

from transformers import pipeline

classify = pipeline("sentiment-analysis")
print(classify("I can't believe how easy this was."))
# [{'label': 'NEGATIVE', 'score': 0.9987}]

Five lines, a real model, a real answer — and look at the answer. The sentence was meant as praise, and the model called it negative, with 99.9% confidence. It read “I can’t believe” the way it usually appears in its training data: as the start of a complaint. That is not a broken model. It is the first lesson of the book, delivered on line five: a model’s output is a verdict, produced by arithmetic over what it has seen, and the number beside it measures how sure the arithmetic is, not how right. You don’t yet know what pipeline is doing or where the model came from — that’s exactly what the book unpacks. But notice the shape of it: load a pretrained thing, hand it an input, read the output. Almost everything you’ll run follows that pattern, and almost everything you’ll learn is how to read what comes back.

What this book covers, and in what order

The order follows one rule: you run a real model as early as possible, and everything about what is inside one waits until you have. By the end you’ll comfortably take a model you found online and run it yourself:

  • Part I — Run your first model. Tensors, moving them to a GPU, and then, in chapter 4, a real pretrained image classifier looking at a real photo. After that: reading shapes, reading outputs, the pipeline() shortcut that collapses most model runs to three lines, how to find and vet models on the Hugging Face Hub (licence included), a debugging playbook for the errors you’ll actually see, and a first capstone that wraps a model in a tiny shareable app. (Six more follow: one at the end of Part II, two in Part III, the chatbot in Part IV, and two in Part V.)
  • Part II — What is inside. Optional, and short: a model read like a spec sheet rather than built. What a model is made of, a real vision model and a real language model opened up, and a capstone that loads weights that aren’t on the Hub at all.
  • Part III — Text, embeddings and search. Tokenizers, dropping below pipeline() to from_pretrained for control, embeddings you can compare and search, and two capstones: a feedback-triage tool and a semantic search engine.
  • Part IV — Generation. Fitting big models into small GPUs, a decoder writing one token at a time, the handful of knobs that control how it picks the next word, chat models, and a chatbot you can talk to.
  • Part V — Audio. Sound as a tensor, text-to-speech from a robotic voice to an expressive one, a narrator that reads an article aloud, how a codec turns audio into tokens, music from a text prompt and the knobs that steer it, and the finale: a scored scene mixed from a generated voice and a generated track.

Seven capstones, each a working app with a link you can send to someone, and not one derivative along the way.

Final thoughts

The single most freeing idea in this book is permission to not learn the math first. The people shipping AI features into products mostly aren’t deriving gradients; they’re running capable pretrained models and wiring them into something useful, and that skill is learnable in an afternoon’s worth of notebooks. PyTorch is just the engine you’re learning to drive — and you can drive it well long before you understand every part under the hood.

Next: Tensors: The One Data Structure You Actually Have to Like.

Comments