Next meetup: SelfEvaluate Agent · Sat, Oct 31, 9:00 AM IST · both mandatory for venue entryRSVPGoogle Form
All postsSession recap

PyTorch Foundations — Tensors, Autograd and the Training Loop

AIYatra Team 1 min read 145 attendedThe Meetup event
PyTorch Foundations — Tensors, Autograd and the Training Loop

Tensors, autograd and the training loop — the foundations every AI engineer stands on. We rebuilt nn.Linear from scratch.

What we covered

Most PyTorch tutorials start with model.fit and never look underneath. We went the other way: raw tensors first, then the autograd engine, then the training loop — so every abstraction above feels earned, not magical.

  • Tensors as the lingua franca — shapes, strides, broadcasting, and why (batch, features) runs the world.
  • Autograd by hand — a tiny scalar engine that builds the computation graph and backpropagates, before touching torch.autograd.
  • The training loop, deconstructed — forward, loss, backward, step, zero-grad. Every line explained, nothing hidden behind a trainer class.

What we built

By the end of the morning, every laptop in the room had a from-scratch linear layer training on real data — then we swapped in nn.Linear and watched the same loop run on the real thing. Same math, same gradients, zero mystery.

Takeaways

  • If you can implement backward() for a scalar graph on paper, PyTorch stops being a black box forever.
  • Shape errors are the compiler telling you your mental model is wrong — read them, don’t fear them.
  • The training loop is five lines. Everything else is convenience.

Join the next one

We run sessions like this every Saturday in Hyderabad — free, hands-on, and open to everyone. RSVP on Meetup and bring a laptop with Python 3.10+.

Have a story of your own? Anyone can write for the AIYatra blog.

Writing guideWrite a guest post