internalsGet Pro

Module 09 · Lesson 4 of 11Pro

Building a neural network in PyTorch

Level
Beginner
Topic
Neural networks
Reading time
14 min

When you finish this page you can

  1. Build a complete PyTorch classifier from a Dataset, a DataLoader, an nn.Module subclass, a loss and an optimizer.
  2. Follow a batch’s shape from photos to class scores, and count the model’s parameters from its layers.
  3. Say what model.train(), model.eval() and torch.no_grad() each change, and when each one is needed.
  4. Save a trained model’s state_dict and load it into fresh code for predictions.

Builds on 4 lessons

Start with lesson 113 min
  1. Neurons and layers: the building blocks13 min
  2. PyTorch tensors: shapes, axes and operations14 min
  3. The training loop: predict, measure, adjust13 min
  4. Train, validation and test sets13 min

Seven wrong categories in every hundred listings

is our example online store. Sellers add new clothes every day and pick each product’s category themselves. In a check of 1,000 new listings, 70 had the wrong one: shirts filed as T-shirts, coats as pullovers.

Our biggest sale ever · Black Friday

Flat 50% Off

Pro

Continue reading

Unlock every course, now and later

  • System Design, live
  • AI Engineering, live
  • Data Engineering, live
  • Machine Learning Engineering, live
  • Inference Engineering, coming soon
  • AI Research, coming soon
  • Performance Engineering, coming soon
  • Agent & Harness Engineering, coming soon
  • LLM Fine-tuning, coming soon
  • LLM Pre-training & Post-training, coming soon
  • Reinforcement Learning, coming soon
  • AI Infrastructure & Platform Engineering, coming soon
  • AI Evaluation & Safety, coming soon
  • Forward Deployed Engineering, coming soon
  • Cloud Computing, coming soon
  • DevOps, coming soon

50% off · Annual and Lifetime

BLACKFRIDAY50Applied at checkout

Choose a plan