def train(model, data):
for epoch in range(10):
loss = model.learn(data)
print(f"epoch {epoch}: {loss:.3f}")
train(neural_net, classroom_data)Learn Python,
then go deeper.
Start with the foundations, run the examples as you learn, then continue into data structures, testing, files, and object behavior.
Python Foundations
Begin here if you are new to Python.
Your First Program
Printing, comments, program headings, escape characters, and four first assignments.
Open chapter โ 02Variables
Data types, variables, strings, numbers, user input, and five assignments.
Open chapter โ 03Functions
Creating, calling, combining, and returning values from functions.
Open chapter โ 04Conditionals
Conditions, if/elif/else, logical operators, nested decisions, assignments, and a project.
Open chapter โ 05Loops
while and for loops, range, nesting, modules, assignments, and three complete projects.
Open chapter โReady after the foundations / New course
Learn deep learning with PyTorch.
Go from Python numbers to a small neural network you can explain. Six lessons cover neurons, gradients, tensors, training, testing, and saving your model. Advanced Python is not required.
Open the deep learning course โAdvanced Python
Continue with larger data structures, concise patterns, testing, files, decorators, and object behavior.
Advanced Overview
Prerequisites, the recommended learning path, and what each advanced chapter adds.
Open chapter โ A01Dictionaries & Tuples
Creating, changing, looping through, formatting, and nesting dictionaries and tuples.
Open chapter โ A01+Dictionary Notes
The complete supplemental dictionary guide with examples, methods, and exercises.
Open chapter โ A02Advanced Functions
Keyword arguments, defaults, arbitrary arguments, and flexible function patterns.
Open chapter โ A03List Comprehension
Building concise lists from loops, expressions, and conditional logic.
Open chapter โ A04Testing Your Code
Unit tests, test cases, assertions, failures, and testing functions and classes.
Open chapter โ A05Reading & Writing Files
File paths, reading, writing, appending, exceptions, JSON, and data persistence.
Open chapter โ A06Decorators
First-class functions, wrappers, arguments, return values, stacking, assignments, and a project.
Open chapter โ A06+Decorator Notes
Supplemental decorator examples, explanations, and linked reference material.
Open chapter โ A07Descriptors
The complete descriptors reference document from the advanced-course archive.
Open chapter โ A08Magic or Dunder Methods
Customizing Python objects and operators with built-in magic methods.
Open chapter โ