# mrdbourke/pytorch-deep-learning architecture

> Architecture diagram of the GitHub repository mrdbourke/pytorch-deep-learning, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mrdbourke/pytorch-deep-learning
- Repository: https://github.com/mrdbourke/pytorch-deep-learning

## Overview

This repository is primarily a hands-on PyTorch course rather than a single production service. Its documented learning path progresses from tensor fundamentals and general workflow through classification, computer vision, custom datasets, modular training, transfer learning, experiment tracking, paper replication, and model deployment. The clearest executable product slice is the modular image-classification pipeline: a script loads directory-based food images, creates DataLoaders, constructs TinyVGG, trains and evaluates it epoch by epoch, then saves weights; a separate prediction utility loads an image and renders its predicted class and probability. Course notebooks, Markdown lessons, exercises, slides, demos, and pretrained artifacts surround that workflow. The graph emphasizes sampled source code and documented course entry points. Deployment and experiment-tracking material are documented in the README but their implementation is not sampled here, so those relationships are intentionally left broad rather than inferred.

Main entry points: [`going_modular/going_modular/engine.py`](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/engine.py) (Training Engine), [`going_modular/going_modular/model_builder.py`](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/model_builder.py) (TinyVGG Model), [`going_modular/going_modular/predictions.py`](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/predictions.py) (Image Predictor), [`going_modular/going_modular/data_setup.py`](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/data_setup.py) (DataLoaders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_course["Course Curriculum"]
  node_fundamentals["PyTorch Fundamentals<br/>course section"]
  node_workflow["PyTorch Workflow<br/>course section"]
  node_vision["Computer Vision<br/>course section"]
  node_customdata["Custom Datasets<br/>course section"]
  node_modular_lesson["Going Modular<br/>course section"]
  node_transfer["Transfer Learning<br/>course section"]
  node_tracking["Experiment Tracking<br/>course section"]
  node_replication["Paper Replication<br/>course section"]
  node_deployment["Model Deployment<br/>course section"]
  node_learner_readme["Course Guide<br/>documentation entry"]
  node_helper_tools["Course Helpers<br/>support utility"]
end

subgraph group_modular["Modular Food Classification"]
  node_dataset[("Food Image Dataset<br/>input data")]
  node_data_loaders["DataLoaders<br/>data preparation"]
  node_tinyvgg{{"TinyVGG Model<br/>model architecture"}}
  node_training_engine["Training Engine<br/>training orchestration"]
  node_train_entry["Training Script<br/>execution entry point"]
  node_loss_optimizer["Loss Optimizer<br/>training configuration"]
  node_metrics["Epoch Metrics<br/>training state"]
end

subgraph group_inference["Image Inference"]
  node_predictor["Image Predictor<br/>inference utility"]
  node_plot_result["Prediction Plot<br/>result presentation"]
end

subgraph group_artifacts["Model Artifacts"]
  node_save_weights["Weight Saver<br/>artifact writer"]
  node_weights[("TinyVGG Weights<br/>model artifact")]
end

node_learner(("Learner<br/>external actor"))
node_image(("Target Image<br/>external input"))
node_pytorch{{"PyTorch Runtime<br/>external dependency"}}

node_learner -->|"starts with"| node_learner_readme
node_learner_readme -->|"follows"| node_fundamentals
node_fundamentals -->|"builds toward"| node_workflow
node_workflow -->|"extends into"| node_vision
node_vision -->|"prepares"| node_customdata
node_customdata -->|"modularizes"| node_modular_lesson
node_modular_lesson -->|"continues to"| node_transfer
node_transfer -->|"supports"| node_tracking
node_tracking -->|"advances to"| node_replication
node_replication -->|"culminates in"| node_deployment
node_dataset -->|"feeds"| node_data_loaders
node_train_entry -->|"creates"| node_data_loaders
node_train_entry -->|"instantiates"| node_tinyvgg
node_data_loaders -->|"provides batches"| node_training_engine
node_tinyvgg -->|"is trained by"| node_training_engine
node_train_entry -->|"orchestrates"| node_training_engine
node_loss_optimizer -->|"configures updates"| node_training_engine
node_training_engine -->|"collects"| node_metrics
node_tinyvgg -->|"parameters"| node_loss_optimizer
node_training_engine -->|"hands model"| node_save_weights
node_save_weights -->|"writes"| node_weights
node_pytorch -.->|"runtime"| node_data_loaders
node_pytorch -.->|"implements"| node_tinyvgg
node_pytorch -.->|"executes"| node_training_engine
node_image -->|"selected for"| node_predictor
node_weights -->|"restores model"| node_predictor
node_tinyvgg -->|"model contract"| node_predictor
node_predictor -->|"renders"| node_plot_result
node_pytorch -.->|"runs inference"| node_predictor
node_helper_tools -->|"can download"| node_dataset

click node_fundamentals "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/00_pytorch_fundamentals.ipynb"
click node_workflow "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/01_pytorch_workflow.ipynb"
click node_vision "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/03_pytorch_computer_vision.ipynb"
click node_customdata "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/04_pytorch_custom_datasets.ipynb"
click node_modular_lesson "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/05_pytorch_going_modular.md"
click node_transfer "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/06_pytorch_transfer_learning.ipynb"
click node_tracking "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/07_pytorch_experiment_tracking.ipynb"
click node_replication "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/08_pytorch_paper_replicating.ipynb"
click node_deployment "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/09_pytorch_model_deployment.ipynb"
click node_learner_readme "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/README.md"
click node_dataset "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/data/pizza_steak_sushi.zip"
click node_data_loaders "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/data_setup.py"
click node_tinyvgg "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/model_builder.py"
click node_training_engine "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/engine.py"
click node_train_entry "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/train.py"
click node_loss_optimizer "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/train.py"
click node_metrics "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/engine.py"
click node_save_weights "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/utils.py"
click node_weights "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/models/05_going_modular_script_mode_tinyvgg_model.pth"
click node_predictor "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/predictions.py"
click node_plot_result "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/predictions.py"
click node_helper_tools "https://github.com/mrdbourke/pytorch-deep-learning/blob/main/helper_functions.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_fundamentals,node_workflow,node_vision,node_customdata,node_modular_lesson,node_transfer,node_tracking,node_replication,node_deployment,node_learner_readme,node_helper_tools toneBlue
class node_dataset,node_data_loaders,node_tinyvgg,node_training_engine,node_train_entry,node_loss_optimizer,node_metrics toneAmber
class node_predictor,node_plot_result toneMint
class node_save_weights,node_weights toneRose
class node_learner,node_image,node_pytorch toneIndigo
```

## Components

### Course Curriculum

Documented lessons and learning entry points

- [PyTorch Fundamentals](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/00_pytorch_fundamentals.ipynb): course section · Tensor and neural-network foundations · `00_pytorch_fundamentals.ipynb`
- [PyTorch Workflow](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/01_pytorch_workflow.ipynb): course section · End-to-end modeling workflow · `01_pytorch_workflow.ipynb`
- [Computer Vision](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/03_pytorch_computer_vision.ipynb): course section · Vision models and datasets · `03_pytorch_computer_vision.ipynb`
- [Custom Datasets](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/04_pytorch_custom_datasets.ipynb): course section · ImageFolder and custom data foundations · `04_pytorch_custom_datasets.ipynb`
- [Going Modular](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/05_pytorch_going_modular.md): course section · Converts notebook work into Python modules · `05_pytorch_going_modular.md`
- [Transfer Learning](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/06_pytorch_transfer_learning.ipynb): course section · Adapts pretrained models · `06_pytorch_transfer_learning.ipynb`
- [Experiment Tracking](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/07_pytorch_experiment_tracking.ipynb): course section · Tracks model experiments · `07_pytorch_experiment_tracking.ipynb`
- [Paper Replication](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/08_pytorch_paper_replicating.ipynb): course section · Research-oriented PyTorch project · `08_pytorch_paper_replicating.ipynb`
- [Model Deployment](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/09_pytorch_model_deployment.ipynb): course section · Publishes a trained FoodVision model · `09_pytorch_model_deployment.ipynb`
- [Course Guide](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/README.md): documentation entry · Course outline and recommended progression · `README.md`
- [Course Helpers](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/helper_functions.py): support utility · Dataset download, plotting, metrics, and reusable helpers · `helper_functions.py`

### Modular Food Classification

Executable TinyVGG training workflow

- [Food Image Dataset](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/data/pizza_steak_sushi.zip): input data · Pizza, steak, and sushi train/test directories · `data/pizza_steak_sushi.zip`
- [DataLoaders](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/data_setup.py): data preparation · ImageFolder datasets, transforms, batching, and class names · `going_modular/going_modular/data_setup.py`
- [TinyVGG Model](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/model_builder.py): model architecture · Two convolution blocks and a classifier · `going_modular/going_modular/model_builder.py`
- [Training Engine](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/engine.py): training orchestration · Epoch loop with train_step and test_step metrics · `going_modular/going_modular/engine.py`
- [Training Script](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/train.py): execution entry point · Configures paths, hyperparameters, model, optimizer, and training · `going_modular/going_modular/train.py`
- [Loss Optimizer](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/train.py): training configuration · CrossEntropyLoss and Adam update model parameters · `going_modular/going_modular/train.py`
- [Epoch Metrics](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/engine.py): training state · Train/test loss and accuracy collected per epoch · `going_modular/going_modular/engine.py`

### Image Inference

Single-image prediction and visualization

- [Image Predictor](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/predictions.py): inference utility · Preprocesses image, runs inference, maps logits to class probability · `going_modular/going_modular/predictions.py`
- [Prediction Plot](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/predictions.py): result presentation · Displays image with predicted class and probability · `going_modular/going_modular/predictions.py`

### Model Artifacts

Persisted trained weights

- [Weight Saver](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/going_modular/utils.py): artifact writer · Writes model state_dict to a .pth/.pt file · `going_modular/going_modular/utils.py`
- [TinyVGG Weights](https://github.com/mrdbourke/pytorch-deep-learning/blob/main/going_modular/models/05_going_modular_script_mode_tinyvgg_model.pth): model artifact · Generated checkpoint; repository also contains pretrained examples · `going_modular/models/05_going_modular_script_mode_tinyvgg_model.pth`

### Other components

- **Learner**: external actor · Student working through notebooks or scripts
- **Target Image**: external input · Image selected for prediction
- **PyTorch Runtime**: external dependency · Tensor, neural-network, optimizer, and inference runtime

## Connections

- Learner → Course Guide: starts with
- Course Guide → PyTorch Fundamentals: follows
- PyTorch Fundamentals → PyTorch Workflow: builds toward
- PyTorch Workflow → Computer Vision: extends into
- Computer Vision → Custom Datasets: prepares
- Custom Datasets → Going Modular: modularizes
- Going Modular → Transfer Learning: continues to
- Transfer Learning → Experiment Tracking: supports
- Experiment Tracking → Paper Replication: advances to
- Paper Replication → Model Deployment: culminates in
- Food Image Dataset → DataLoaders: feeds
- Training Script → DataLoaders: creates
- Training Script → TinyVGG Model: instantiates
- DataLoaders → Training Engine: provides batches
- TinyVGG Model → Training Engine: is trained by
- Training Script → Training Engine: orchestrates
- Loss Optimizer → Training Engine: configures updates
- Training Engine → Epoch Metrics: collects
- TinyVGG Model → Loss Optimizer: parameters
- Training Engine → Weight Saver: hands model
- Weight Saver → TinyVGG Weights: writes
- PyTorch Runtime → DataLoaders: runtime
- PyTorch Runtime → TinyVGG Model: implements
- PyTorch Runtime → Training Engine: executes
- Target Image → Image Predictor: selected for
- TinyVGG Weights → Image Predictor: restores model
- TinyVGG Model → Image Predictor: model contract
- Image Predictor → Prediction Plot: renders
- PyTorch Runtime → Image Predictor: runs inference
- Course Helpers → Food Image Dataset: can download
