-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bf7a3ec
Showing
32 changed files
with
800 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
layout conda template | ||
|
||
export PATH=$PWD:$PWD/scripts:$PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
### Python ### | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
### Lightning-Template ### | ||
/data/* | ||
!/data/.gitkeep | ||
/models/* | ||
!/models/.gitkeep | ||
/results/* | ||
!/results/.gitkeep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.1.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-added-large-files | ||
|
||
- repo: https://github.com/hadialqattan/pycln | ||
rev: v1.2.2 | ||
hooks: | ||
- id: pycln | ||
args: [--config=pyproject.toml, --silence] | ||
|
||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v2.31.0 | ||
hooks: | ||
- id: pyupgrade | ||
args: [--py39-plus] | ||
|
||
- repo: https://github.com/pycqa/isort | ||
rev: 5.10.1 | ||
hooks: | ||
- id: isort | ||
|
||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: v2.5.1 | ||
hooks: | ||
- id: prettier | ||
types: [yaml] | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 22.1.0 | ||
hooks: | ||
- id: black |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Lightning-Template | ||
|
||
A clean and scalable template to structure ML paper-code the same so that work can easily be extended and replicated. | ||
|
||
### DELETE EVERYTHING ABOVE FOR YOUR PROJECT | ||
|
||
--- | ||
|
||
<div align="center"> | ||
|
||
# Your Project Name | ||
|
||
[![Paper](http://img.shields.io/badge/paper-arxiv.1001.2234-B31B1B.svg)](https://www.nature.com/articles/nature14539) | ||
[![Conference](http://img.shields.io/badge/NeurIPS-2019-4b44ce.svg)](https://papers.nips.cc/book/advances-in-neural-information-processing-systems-31-2018) | ||
[![Conference](http://img.shields.io/badge/ICLR-2019-4b44ce.svg)](https://papers.nips.cc/book/advances-in-neural-information-processing-systems-31-2018) | ||
[![Conference](http://img.shields.io/badge/AnyConference-year-4b44ce.svg)](https://papers.nips.cc/book/advances-in-neural-information-processing-systems-31-2018) | ||
<!-- | ||
ARXIV | ||
[![Paper](http://img.shields.io/badge/arxiv-math.co:1480.1111-B31B1B.svg)](https://www.nature.com/articles/nature14539) | ||
--> | ||
|
||
|
||
<!-- | ||
Conference | ||
--> | ||
</div> | ||
|
||
## Description | ||
What it does | ||
|
||
## How to run | ||
First, install dependencies | ||
```bash | ||
# clone project | ||
git clone https://github.com/YourGithubName/your-repository-name | ||
cd your-repository-name | ||
|
||
# [OPTIONAL] create conda environment | ||
conda create -n template python=3.9 | ||
conda activate template | ||
|
||
# install requirements | ||
pip install -r requirements.txt | ||
``` | ||
|
||
Next, run experiments with the `run` script. | ||
```bash | ||
# fit with the demo config | ||
./run fit --config configs/demo.yaml | ||
# or specific command line arguments | ||
./run fit --model MNISTModel --data MNISTDataModule --data.batch_size 32 --trainer.gpus 0 | ||
|
||
# evaluate with the checkpoint | ||
./run test --config configs/demo.yaml --ckpt_path ckpt_path | ||
|
||
# get the script help | ||
./run --help | ||
./run fit --help | ||
``` | ||
|
||
## Citation | ||
``` | ||
@article{YourName, | ||
title={Your Title}, | ||
author={Your team}, | ||
journal={Location}, | ||
year={Year} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: mnist | ||
seed_everything: 123 | ||
trainer: | ||
max_epochs: 20 | ||
model: | ||
class_path: src.models.MNISTModel | ||
data: | ||
class_path: src.datamodules.MNISTDataModule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
trainer: | ||
gpus: 4 | ||
strategy: "ddp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
trainer: | ||
gpus: 0 | ||
max_epochs: 1 | ||
detect_anomaly: true | ||
enable_checkpointing: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
seed_everything: 42 | ||
trainer: | ||
logger: | ||
class_path: pytorch_lightning.loggers.TensorBoardLogger | ||
init_args: | ||
save_dir: "results" | ||
gpus: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
trainer: | ||
max_epochs: 5 | ||
limit_train_batches: 10 | ||
limit_val_batches: 5 | ||
limit_test_batches: 5 | ||
enable_checkpointing: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
trainer: | ||
overfit_batches: 0.01 | ||
enable_checkpointing: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
trainer: | ||
max_epochs: 1 | ||
profiler: "simple" | ||
# profiler: "advanced" | ||
# profiler: "pytorch" | ||
enable_checkpointing: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
trainer: | ||
fast_dev_run: 5 |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# https://github.com/psf/black | ||
[tool.black] | ||
line-length = 88 | ||
|
||
# https://github.com/timothycrosley/isort/ | ||
[tool.isort] | ||
profile = "black" | ||
line_length = 88 | ||
combine_as_imports = true | ||
combine_star = true | ||
|
||
# https://github.com/hadialqattan/pycln | ||
[tool.pycln] | ||
all = true | ||
|
||
# https://github.com/microsoft/pyright | ||
[tool.pyright] | ||
venv = "template" | ||
typeCheckingMode = "off" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
torch >= 1.10.0 | ||
torchvision >= 0.11.0 | ||
pytorch-lightning >= 1.5.0 | ||
jsonargparse[signatures,jsonnet] >= 4.3.0 | ||
shtab >= 1.5.0 | ||
rich >= 11.0.0 | ||
|
||
jupyterlab |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python | ||
|
||
import argparse | ||
import os | ||
|
||
from pytorch_lightning import LightningDataModule, LightningModule | ||
from pytorch_lightning.utilities.cli import DATAMODULE_REGISTRY, MODEL_REGISTRY | ||
|
||
import src.datamodules | ||
import src.models | ||
from src.utils import LitCLI | ||
|
||
MODEL_REGISTRY.register_classes(src.models, LightningModule) | ||
DATAMODULE_REGISTRY.register_classes(src.datamodules, LightningDataModule) | ||
|
||
|
||
def main(): | ||
os.chdir(os.path.dirname(__file__)) | ||
|
||
cli = LitCLI( | ||
parser_kwargs={ | ||
"default_config_files": ["configs/presets/default.yaml"], | ||
"epilog": f""" | ||
Availabed Models: {list(MODEL_REGISTRY)} | ||
Availabed Datamodules: {list(DATAMODULE_REGISTRY)} | ||
""", | ||
"formatter_class": argparse.RawDescriptionHelpFormatter, | ||
}, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .mnist_datamodule import MNISTDataModule |
Empty file.
Oops, something went wrong.