# jcjohnson/pytorch-examples

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/jcjohnson-pytorch-examples).**

4,872 stars · 917 forks · Python · mit

## Links

- GitHub: https://github.com/jcjohnson/pytorch-examples
- awesome-repositories: https://awesome-repositories.com/repository/jcjohnson-pytorch-examples.md

## Description

This repository provides a curated collection of self-contained Python code examples that demonstrate the core capabilities of the PyTorch deep learning framework. The examples cover automatic differentiation, dynamic computational graphs, GPU‑accelerated tensor operations, and training of neural network models using gradient‑based optimization.

The code samples illustrate PyTorch’s dynamic graph construction, where models can change structure with native control flow, and its automatic gradient computation through reverse‑mode differentiation. Additional examples show how to work with tensors on both CPU and GPU, define custom neural network layers using the module system, and apply optimizers such as SGD, Adam, and RMSProp. The collection also includes tutorials on building computational graphs and training loops, making it a practical reference for learning PyTorch’s essential features.

## Tags

### Education & Learning Resources

- [Learning Examples](https://awesome-repositories.com/f/education-learning-resources/learning-examples.md) — Provides a curated collection of self-contained PyTorch code examples for learning.

### Artificial Intelligence & ML

- [Automatic Differentiation](https://awesome-repositories.com/f/artificial-intelligence-ml/automatic-differentiation.md) — Computes gradients automatically via computational graph and backpropagation. ([source](https://github.com/jcjohnson/pytorch-examples/blob/master/README.md))
- [Custom Neural Network Layers](https://awesome-repositories.com/f/artificial-intelligence-ml/custom-neural-network-layers.md) — Creates custom neural network layers with learnable parameters via subclassing.
- [Dynamic Graph Builders](https://awesome-repositories.com/f/artificial-intelligence-ml/gradient-computation/dynamic-graph-builders.md) — Illustrates dynamic computational graphs built on-the-fly with native Python control flow. ([source](https://github.com/jcjohnson/pytorch-examples#readme))
- [Tensor Computing Libraries](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-optimization-and-inference/hardware-and-acceleration/tensor-computing-libraries.md) — Demonstrates performing tensor operations on GPUs for accelerated numerical computation. ([source](https://github.com/jcjohnson/pytorch-examples#readme))
- [Neural Network Layers](https://awesome-repositories.com/f/artificial-intelligence-ml/neural-network-layers.md) — Shows how to construct neural networks using pre-built layers like dense and convolutional ones. ([source](https://github.com/jcjohnson/pytorch-examples#readme))
- [Neural Network Modules](https://awesome-repositories.com/f/artificial-intelligence-ml/neural-network-modules.md) — Demonstrates creating custom neural network layers by subclassing PyTorch's Module class. ([source](https://github.com/jcjohnson/pytorch-examples/blob/master/README.md))
- [Neural Network Training](https://awesome-repositories.com/f/artificial-intelligence-ml/neural-network-training.md) — Trains neural networks by defining models, computing gradients, and applying optimizers.
- [Neural Network Optimizers](https://awesome-repositories.com/f/artificial-intelligence-ml/optimization-algorithms/neural-network-optimizers.md) — Provides examples of training neural networks with various optimizers including SGD, Adam, and RMSProp. ([source](https://github.com/jcjohnson/pytorch-examples#readme))
- [Reverse-Mode Differentiation](https://awesome-repositories.com/f/artificial-intelligence-ml/reverse-mode-differentiation.md) — Implements reverse-mode automatic differentiation for computing gradients via backpropagation.
- [Stochastic Gradient Descent Optimizations](https://awesome-repositories.com/f/artificial-intelligence-ml/stochastic-gradient-descent-optimizations.md) — Applies stochastic gradient descent and Adam optimizers to minimize loss functions.
- [GPU Tensor Mapping](https://awesome-repositories.com/f/artificial-intelligence-ml/gpu-tensor-mapping.md) — Demonstrates GPU tensor mapping and computation with code samples.
- [Custom Autograd Functions](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/frameworks/model-construction/automatic-differentiation-systems/functional-autograd/custom-autograd-functions.md) — Defines custom autograd functions with user-specified forward and backward operations. ([source](https://github.com/jcjohnson/pytorch-examples/blob/master/README.md))
- [Model Training Optimizers](https://awesome-repositories.com/f/artificial-intelligence-ml/model-training-optimizers.md) — Illustrates training loops with optimizers like SGD and Adam.

### Data & Databases

- [GPU-Accelerated Processing](https://awesome-repositories.com/f/data-databases/large-scale-dataset-management/gpu-accelerated-processing.md) — Enables GPU-accelerated tensor operations via CUDA backend for parallel computation.

### Programming Languages & Runtimes

- [Neural Network Module Abstractions](https://awesome-repositories.com/f/programming-languages-runtimes/class-based-architecture/neural-network-module-abstractions.md) — Provides module-based abstractions for encapsulating neural network layers and parameters.
- [Eager Execution Modes](https://awesome-repositories.com/f/programming-languages-runtimes/runtime-execution-environments/runtime-environments/runtimes/graph-symbolic-execution-engines/hybrid-execution-modes/eager-execution-modes.md) — Demonstrates eager execution mode for immediate evaluation and debugging.
