# pytorch/examples architecture

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

- Interactive diagram: https://gitdiagram.com/pytorch/examples
- Repository: https://github.com/pytorch/examples

## Overview

PyTorch Examples is a curated collection of independent, runnable examples rather than one application. A user selects an example, supplies data or settings, and explores a task-specific result such as a trained model, prediction, or distributed training run. The graph preserves the README’s main capability areas and sampled internal layers. Edges between examples and their internal components are limited to relationships shown in the README or source index; unsampled example internals are not inferred.

Main entry points: [`fast_neural_style/neural_style/neural_style.py`](https://github.com/pytorch/examples/blob/main/fast_neural_style/neural_style/neural_style.py) (Neural Style Transfer), [`language_translation/main.py`](https://github.com/pytorch/examples/blob/main/language_translation/main.py) (Language Translation), [`distributed/minGPT-ddp/mingpt/main.py`](https://github.com/pytorch/examples/blob/main/distributed/minGPT-ddp/mingpt/main.py) (Distributed minGPT), [`super_resolution/main.py`](https://github.com/pytorch/examples/blob/main/super_resolution/main.py) (Super Resolution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vision["Vision Examples"]
  node_mnist["MNIST ConvNet<br/>[main.py]"]
  node_imagenet["ImageNet Classifiers<br/>[main.py]"]
  node_dcgan["DCGAN<br/>[main.py]"]
  node_vae["Variational Autoencoder<br/>[main.py]"]
  node_superres["Super Resolution<br/>[main.py]"]
  node_superres_data["Image Data<br/>[data.py]"]
  node_style["Neural Style Transfer<br/>[neural_style.py]"]
  node_style_net["Transformer Network<br/>[transformer_net.py]"]
  node_style_vgg["VGG Features<br/>[vgg.py]"]
end

subgraph group_language["Language Examples"]
  node_language_model["Word Language Model<br/>[main.py]"]
  node_translation["Language Translation<br/>[main.py]"]
  node_translation_data["Translation Data<br/>[data.py]"]
  node_translation_model["Translator Model<br/>[model.py]"]
  node_snli["SNLI Inference<br/>[train.py]"]
  node_snli_model["SNLI Classifier<br/>[model.py]"]
end

subgraph group_learning["Learning Examples"]
  node_reinforcement["Reinforcement Learning<br/>[actor_critic.py]"]
  node_forward_forward["Forward-Forward<br/>[main.py]"]
  node_cpp_transfer["C++ Transfer Learning<br/>[main.cpp]"]
  node_cpp_api["C++ Frontend<br/>[autograd.cpp]"]
end

subgraph group_framework["Framework Examples"]
  node_fx["FX Transformations<br/>[module_tracer.py]"]
end

subgraph group_distributed["Distributed Examples"]
  node_ddp["Distributed Data Parallel<br/>[example.py]"]
  node_fsdp["FSDP Training<br/>[T5_training.py]"]
  node_rpc_rnn["RPC RNN<br/>[main.py]"]
  node_rpc_model["RPC RNN Model<br/>[rnn.py]"]
  node_min_gpt["Distributed minGPT<br/>[main.py]"]
  node_min_gpt_data["Character Dataset<br/>[char_dataset.py]"]
  node_min_gpt_trainer["GPT Trainer<br/>[trainer.py]"]
end

node_user(("Example User"))

node_user -->|"explores"| node_mnist
node_user -->|"explores"| node_imagenet
node_user -->|"explores"| node_dcgan
node_user -->|"explores"| node_vae
node_user -->|"explores"| node_superres
node_user -->|"explores"| node_style
node_user -->|"explores"| node_language_model
node_user -->|"explores"| node_translation
node_user -->|"explores"| node_snli
node_user -->|"explores"| node_reinforcement
node_user -->|"explores"| node_forward_forward
node_user -->|"explores"| node_cpp_transfer
node_user -->|"explores"| node_cpp_api
node_user -->|"explores"| node_fx
node_user -->|"explores"| node_ddp
node_user -->|"explores"| node_fsdp
node_user -->|"explores"| node_rpc_rnn
node_user -->|"explores"| node_min_gpt
node_superres -->|"loads data"| node_superres_data
node_translation -->|"uses data"| node_translation_data
node_translation -->|"uses model"| node_translation_model
node_snli -->|"uses classifier"| node_snli_model
node_style -->|"uses network"| node_style_net
node_style -->|"uses features"| node_style_vgg
node_rpc_rnn -->|"invokes model"| node_rpc_model
node_min_gpt -->|"creates dataset"| node_min_gpt_data
node_min_gpt -->|"creates trainer"| node_min_gpt_trainer

click node_mnist "https://github.com/pytorch/examples/blob/main/mnist/main.py"
click node_imagenet "https://github.com/pytorch/examples/blob/main/imagenet/main.py"
click node_dcgan "https://github.com/pytorch/examples/blob/main/dcgan/main.py"
click node_vae "https://github.com/pytorch/examples/blob/main/vae/main.py"
click node_superres "https://github.com/pytorch/examples/blob/main/super_resolution/main.py"
click node_superres_data "https://github.com/pytorch/examples/blob/main/super_resolution/data.py"
click node_style "https://github.com/pytorch/examples/blob/main/fast_neural_style/neural_style/neural_style.py"
click node_style_net "https://github.com/pytorch/examples/blob/main/fast_neural_style/neural_style/transformer_net.py"
click node_style_vgg "https://github.com/pytorch/examples/blob/main/fast_neural_style/neural_style/vgg.py"
click node_language_model "https://github.com/pytorch/examples/blob/main/word_language_model/main.py"
click node_translation "https://github.com/pytorch/examples/blob/main/language_translation/main.py"
click node_translation_data "https://github.com/pytorch/examples/blob/main/language_translation/src/data.py"
click node_translation_model "https://github.com/pytorch/examples/blob/main/language_translation/src/model.py"
click node_snli "https://github.com/pytorch/examples/blob/main/legacy/snli/train.py"
click node_snli_model "https://github.com/pytorch/examples/blob/main/legacy/snli/model.py"
click node_reinforcement "https://github.com/pytorch/examples/blob/main/reinforcement_learning/actor_critic.py"
click node_forward_forward "https://github.com/pytorch/examples/blob/main/mnist_forward_forward/main.py"
click node_cpp_transfer "https://github.com/pytorch/examples/blob/main/cpp/transfer-learning/main.cpp"
click node_cpp_api "https://github.com/pytorch/examples/blob/main/cpp/autograd/autograd.cpp"
click node_fx "https://github.com/pytorch/examples/blob/main/fx/module_tracer.py"
click node_ddp "https://github.com/pytorch/examples/blob/main/distributed/ddp/example.py"
click node_fsdp "https://github.com/pytorch/examples/blob/main/distributed/FSDP/T5_training.py"
click node_rpc_rnn "https://github.com/pytorch/examples/blob/main/distributed/rpc/rnn/main.py"
click node_rpc_model "https://github.com/pytorch/examples/blob/main/distributed/rpc/rnn/rnn.py"
click node_min_gpt "https://github.com/pytorch/examples/blob/main/distributed/minGPT-ddp/mingpt/main.py"
click node_min_gpt_data "https://github.com/pytorch/examples/blob/main/distributed/minGPT-ddp/mingpt/char_dataset.py"
click node_min_gpt_trainer "https://github.com/pytorch/examples/blob/main/distributed/minGPT-ddp/mingpt/trainer.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_mnist,node_imagenet,node_dcgan,node_vae,node_superres,node_superres_data,node_style,node_style_net,node_style_vgg,node_user toneBlue
class node_language_model,node_translation,node_translation_data,node_translation_model,node_snli,node_snli_model toneAmber
class node_reinforcement,node_forward_forward,node_cpp_transfer,node_cpp_api toneMint
class node_fx toneRose
class node_ddp,node_fsdp,node_rpc_rnn,node_rpc_model,node_min_gpt,node_min_gpt_data,node_min_gpt_trainer toneIndigo
```

## Components

### Vision Examples

- [MNIST ConvNet](https://github.com/pytorch/examples/blob/main/mnist/main.py): `mnist/main.py`
- [ImageNet Classifiers](https://github.com/pytorch/examples/blob/main/imagenet/main.py): `imagenet/main.py`
- [DCGAN](https://github.com/pytorch/examples/blob/main/dcgan/main.py): `dcgan/main.py`
- [Variational Autoencoder](https://github.com/pytorch/examples/blob/main/vae/main.py): `vae/main.py`
- [Super Resolution](https://github.com/pytorch/examples/blob/main/super_resolution/main.py): `super_resolution/main.py`
- [Image Data](https://github.com/pytorch/examples/blob/main/super_resolution/data.py): `super_resolution/data.py`
- [Neural Style Transfer](https://github.com/pytorch/examples/blob/main/fast_neural_style/neural_style/neural_style.py): `fast_neural_style/neural_style/neural_style.py`
- [Transformer Network](https://github.com/pytorch/examples/blob/main/fast_neural_style/neural_style/transformer_net.py): `fast_neural_style/neural_style/transformer_net.py`
- [VGG Features](https://github.com/pytorch/examples/blob/main/fast_neural_style/neural_style/vgg.py): `fast_neural_style/neural_style/vgg.py`

### Language Examples

- [Word Language Model](https://github.com/pytorch/examples/blob/main/word_language_model/main.py): `word_language_model/main.py`
- [Language Translation](https://github.com/pytorch/examples/blob/main/language_translation/main.py): `language_translation/main.py`
- [Translation Data](https://github.com/pytorch/examples/blob/main/language_translation/src/data.py): `language_translation/src/data.py`
- [Translator Model](https://github.com/pytorch/examples/blob/main/language_translation/src/model.py): `language_translation/src/model.py`
- [SNLI Inference](https://github.com/pytorch/examples/blob/main/legacy/snli/train.py): `legacy/snli/train.py`
- [SNLI Classifier](https://github.com/pytorch/examples/blob/main/legacy/snli/model.py): `legacy/snli/model.py`

### Learning Examples

- [Reinforcement Learning](https://github.com/pytorch/examples/blob/main/reinforcement_learning/actor_critic.py): `reinforcement_learning/actor_critic.py`
- [Forward-Forward](https://github.com/pytorch/examples/blob/main/mnist_forward_forward/main.py): `mnist_forward_forward/main.py`
- [C++ Transfer Learning](https://github.com/pytorch/examples/blob/main/cpp/transfer-learning/main.cpp): `cpp/transfer-learning/main.cpp`
- [C++ Frontend](https://github.com/pytorch/examples/blob/main/cpp/autograd/autograd.cpp): `cpp/autograd/autograd.cpp`

### Framework Examples

- [FX Transformations](https://github.com/pytorch/examples/blob/main/fx/module_tracer.py): `fx/module_tracer.py`

### Distributed Examples

- [Distributed Data Parallel](https://github.com/pytorch/examples/blob/main/distributed/ddp/example.py): `distributed/ddp/example.py`
- [FSDP Training](https://github.com/pytorch/examples/blob/main/distributed/FSDP/T5_training.py): `distributed/FSDP/T5_training.py`
- [RPC RNN](https://github.com/pytorch/examples/blob/main/distributed/rpc/rnn/main.py): `distributed/rpc/rnn/main.py`
- [RPC RNN Model](https://github.com/pytorch/examples/blob/main/distributed/rpc/rnn/rnn.py): `distributed/rpc/rnn/rnn.py`
- [Distributed minGPT](https://github.com/pytorch/examples/blob/main/distributed/minGPT-ddp/mingpt/main.py): `distributed/minGPT-ddp/mingpt/main.py`
- [Character Dataset](https://github.com/pytorch/examples/blob/main/distributed/minGPT-ddp/mingpt/char_dataset.py): `distributed/minGPT-ddp/mingpt/char_dataset.py`
- [GPT Trainer](https://github.com/pytorch/examples/blob/main/distributed/minGPT-ddp/mingpt/trainer.py): `distributed/minGPT-ddp/mingpt/trainer.py`

### Other components

- **Example User**

## Connections

- Example User → MNIST ConvNet: explores (evidence: `README.md`)
- Example User → ImageNet Classifiers: explores (evidence: `README.md`)
- Example User → DCGAN: explores (evidence: `README.md`)
- Example User → Variational Autoencoder: explores (evidence: `README.md`)
- Example User → Super Resolution: explores (evidence: `README.md`)
- Example User → Neural Style Transfer: explores (evidence: `README.md`)
- Example User → Word Language Model: explores (evidence: `README.md`)
- Example User → Language Translation: explores (evidence: `README.md`)
- Example User → SNLI Inference: explores (evidence: `README.md`)
- Example User → Reinforcement Learning: explores (evidence: `README.md`)
- Example User → Forward-Forward: explores (evidence: `README.md`)
- Example User → C++ Transfer Learning: explores (evidence: `README.md`)
- Example User → C++ Frontend: explores (evidence: `README.md`)
- Example User → FX Transformations: explores (evidence: `README.md`)
- Example User → Distributed Data Parallel: explores (evidence: `README.md`)
- Example User → FSDP Training: explores (evidence: `README.md`)
- Example User → RPC RNN: explores (evidence: `README.md`)
- Example User → Distributed minGPT: explores (evidence: `README.md`)
- Super Resolution → Image Data: loads data (evidence: `super_resolution/main.py`)
- Language Translation → Translation Data: uses data (evidence: `language_translation/main.py`)
- Language Translation → Translator Model: uses model (evidence: `language_translation/main.py`)
- SNLI Inference → SNLI Classifier: uses classifier (evidence: `legacy/snli/train.py`)
- Neural Style Transfer → Transformer Network: uses network (evidence: `fast_neural_style/neural_style/neural_style.py`)
- Neural Style Transfer → VGG Features: uses features (evidence: `fast_neural_style/neural_style/neural_style.py`)
- RPC RNN → RPC RNN Model: invokes model (evidence: `distributed/rpc/rnn/main.py`)
- Distributed minGPT → Character Dataset: creates dataset (evidence: `distributed/minGPT-ddp/mingpt/main.py`)
- Distributed minGPT → GPT Trainer: creates trainer (evidence: `distributed/minGPT-ddp/mingpt/main.py`)
