This repository provides annotated single-file examples for learning PyTorch.
- Fundamentals
- Linear Regression
- Logistic Regression
- MultiLayer Perceptron
- Convolutional Neural Network
- ... (more to come)
uv needs to be available on your system.
git clone https://github.com/bpesquet/pytorch-tutorial.git
cd pytorch-tutorial
uv sync
uv run python {path to example file}This project is built with the following software:
# Format all Python files
uvx ruff format
# Lint all Python files and fix any fixable errors
uvx ruff check --fix
# Run all code examples as unit tests.
# The optional -s flag prints code output.
uv run pytest [-s]Creative Commons for textual content and MIT for code.
Copyright © 2025-present Baptiste Pesquet.