2021-01-07 05:24:47 +00:00
## Basic Examples
2021-08-03 18:19:09 +00:00
2021-10-26 17:38:56 +00:00
Use these examples to test how Lightning works.
2019-10-05 18:13:55 +00:00
2022-06-29 15:18:07 +00:00
### AutoEncoder
2021-11-02 15:13:01 +00:00
This script shows you how to implement a CNN auto-encoder.
```bash
# CPU
python autoencoder.py
# GPUs (any number)
2022-03-28 14:44:59 +00:00
python autoencoder.py --trainer.accelerator 'gpu' --trainer.devices 2
2021-11-02 15:13:01 +00:00
# Distributed Data Parallel (DDP)
2022-03-28 14:44:59 +00:00
python autoencoder.py --trainer.accelerator 'gpu' --trainer.devices 2 --trainer.strategy 'ddp'
2021-11-02 15:13:01 +00:00
```
______________________________________________________________________
2022-06-29 15:18:07 +00:00
### Backbone Image Classifier
2021-11-02 15:13:01 +00:00
This script shows you how to implement a `LightningModule` as a system.
A system describes a `LightningModule` which takes a single `torch.nn.Module` which makes exporting to producion simpler.
```bash
# CPU
python backbone_image_classifier.py
# GPUs (any number)
2022-03-28 14:44:59 +00:00
python backbone_image_classifier.py --trainer.accelerator 'gpu' --trainer.devices 2
2021-11-02 15:13:01 +00:00
# Distributed Data Parallel (DDP)
2022-03-28 14:44:59 +00:00
python backbone_image_classifier.py --trainer.accelerator 'gpu' --trainer.devices 2 --trainer.strategy 'ddp'
2021-11-02 15:13:01 +00:00
```
______________________________________________________________________
2023-04-06 18:32:23 +00:00
### Transformers
This example contains a simple training loop for next-word prediction with a [Transformer model ](https://arxiv.org/abs/1706.03762 ) on a subset of the [WikiText2 ](https://www.salesforce.com/products/einstein/ai-research/the-wikitext-dependency-language-modeling-dataset/ ) dataset.
```bash
python transformer.py
```
______________________________________________________________________
2022-06-29 15:18:07 +00:00
### PyTorch Profiler
2021-11-02 15:13:01 +00:00
This script shows you how to activate the [PyTorch Profiler ](https://github.com/pytorch/kineto ) with Lightning.
```bash
python profiler_example.py
2020-09-23 04:19:46 +00:00
```