All Projects โ†’ lucmos โ†’ Nn Template

lucmos / Nn Template

Licence: mit
Generic template to bootstrap your PyTorch project with PyTorch Lightning, Hydra, W&B, and DVC.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Nn Template

lightning-hydra-template
PyTorch Lightning + Hydra. A very user-friendly template for rapid and reproducible ML experimentation with best practices. โšก๐Ÿ”ฅโšก
Stars: โœญ 1,905 (+1213.79%)
Mutual labels:  research, best-practices, hydra, reproducibility
alchemy
Experiments logging & visualization
Stars: โœญ 49 (-66.21%)
Mutual labels:  research, reproducibility
Catalyst
Accelerated deep learning R&D
Stars: โœญ 2,804 (+1833.79%)
Mutual labels:  research, reproducibility
Pytorch Project Template
Deep Learning project template for PyTorch (Distributed Learning is supported)
Stars: โœญ 76 (-47.59%)
Mutual labels:  hydra, template
Reproducibilty-Challenge-ECANET
Unofficial Implementation of ECANets (CVPR 2020) for the Reproducibility Challenge 2020.
Stars: โœญ 27 (-81.38%)
Mutual labels:  research, reproducibility
Tensorflow Project Template
A best practice for tensorflow project template architecture.
Stars: โœญ 3,466 (+2290.34%)
Mutual labels:  best-practices, template
Vite Electron Builder
Electron app boilerplate based on Vite. TypeScript + Vue/React/Angular/Svelte/Vanilla
Stars: โœญ 96 (-33.79%)
Mutual labels:  best-practices, template
Eros Template
๐Ÿ”ง eros app ๅผ€ๅ‘ๆจกๆฟใ€‚
Stars: โœญ 143 (-1.38%)
Mutual labels:  template
Moderncppstarter
๐Ÿš€ Kick-start your C++! A template for modern C++ projects using CMake, CI, code coverage, clang-format, reproducible dependency management and much more.
Stars: โœญ 2,381 (+1542.07%)
Mutual labels:  template
Uicard
Generic UI for card games like Hearthstone, Magic Arena and Slay the Spire...
Stars: โœญ 142 (-2.07%)
Mutual labels:  template
Tedivms Flask
Flask starter app with celery, bootstrap, and docker environment
Stars: โœญ 142 (-2.07%)
Mutual labels:  template
Android Template
Android app starter template
Stars: โœญ 141 (-2.76%)
Mutual labels:  template
React Bits
โœจ React patterns, techniques, tips and tricks โœจ
Stars: โœญ 11,572 (+7880.69%)
Mutual labels:  best-practices
Electrophysiologydata
A list of openly available datasets in (mostly human) electrophysiology.
Stars: โœญ 143 (-1.38%)
Mutual labels:  research
Warp Api Starter Template
A boilerplate template for starting a web services using Warp + SQLx (PostgreSQL) + Redis + Juniper (GraphQL). โค๏ธ
Stars: โœญ 145 (+0%)
Mutual labels:  template
Touch Bar Istats
Show CPU/GPU/MEM temperature on Touch Bar with BetterTouchTool!
Stars: โœญ 141 (-2.76%)
Mutual labels:  template
Vue Master Class
๐Ÿ—‚ Source code for The Vue 2 Master Class
Stars: โœญ 147 (+1.38%)
Mutual labels:  best-practices
Myriam
A vulnerable iOS App with Security Challenges for the Security Researcher inside you.
Stars: โœญ 146 (+0.69%)
Mutual labels:  research
Dagger2
Kotlin Dagger2 example project
Stars: โœญ 145 (+0%)
Mutual labels:  best-practices
Devmvp
ไธ€้”ฎ็”ŸๆˆMVPๆžถๆž„ๅŸบ็ก€ไปฃ็ -Android Studioๆจกๆฟ
Stars: โœญ 145 (+0%)
Mutual labels:  template

NN Template

PyTorch Lightning Conf: hydra Logging: wandb Conf: hydra Code style: black

Generic template to bootstrap your PyTorch project. Click on Use this Template and avoid writing boilerplate code for:

  • PyTorch Lightning, lightweight PyTorch wrapper for high-performance AI research.
  • Hydra, a framework for elegantly configuring complex applications.
  • DVC, track large files, directories, or ML models. Think "Git for data".
  • Weights and Biases, organize and analyze machine learning experiments. (educational account available)

nn-template is opinionated so you don't have to be. If you use this template, please add to your README.

Usage Examples

Checkout the mwe branch to view a minimum working example on MNIST.

Structure

.
โ”œโ”€โ”€ conf                # Hydra compositional config
โ”‚   โ”œโ”€โ”€ default.yaml    # current experiment configuration
โ”‚   โ”œโ”€โ”€ data
โ”‚   โ”œโ”€โ”€ hydra
โ”‚   โ”œโ”€โ”€ logging
โ”‚   โ”œโ”€โ”€ model
โ”‚   โ”œโ”€โ”€ optim
โ”‚   โ””โ”€โ”€ train
โ”œโ”€โ”€ data                # datasets
โ”œโ”€โ”€ experiments         # local logs
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ requirements.txt    # basic requirements
โ””โ”€โ”€ src
    โ”œโ”€โ”€ common          # common Python modules
    โ”œโ”€โ”€ pl_data         # PyTorch Lightning datamodules and datasets
    โ”œโ”€โ”€ pl_modules      # PyTorch Lightning modules
    โ””โ”€โ”€ run.py          # entry point to run current conf

Data Version Control

DVC runs alongside git and uses the current commit hash to version control the data.

Initialize the dvc repository:

$ dvc init

To start tracking a file or directory, use dvc add:

$ dvc add data/ImageNet

DVC stores information about the added file (or a directory) in a special .dvc file named data/ImageNet.dvc, a small text file with a human-readable format. This file can be easily versioned like source code with Git, as a placeholder for the original data (which gets listed in .gitignore):

git add data/ImageNet.dvc data/.gitignore
git commit -m "Add raw data"

Making changes

When you make a change to a file or directory, run dvc add again to track the latest version:

$ dvc add data/ImageNet

Switching between versions

The regular workflow is to use git checkout first to switch a branch, checkout a commit, or a revision of a .dvc file, and then run dvc checkout to sync data:

$ git checkout <...>
$ dvc checkout

Read more in the docs!

Weights and Biases

Weights & Biases helps you keep track of your machine learning projects. Use tools to log hyperparameters and output metrics from your runs, then visualize and compare results and quickly share findings with your colleagues.

This is an example of a simple dashboard.

Quickstart

Login to your wandb account, running once wandb login. Configure the logging in conf/logging/*.


Read more in the docs. Particularly useful the log method, accessible from inside a PyTorch Lightning module with self.logger.experiment.log.

W&B is our logger of choice, but that is a purely subjective decision. Since we are using Lightning, you can replace wandb with the logger you prefer (you can even build your own). More about Lightning loggers here.

Hydra

Hydra is an open-source Python framework that simplifies the development of research and other complex applications. The key feature is the ability to dynamically create a hierarchical configuration by composition and override it through config files and the command line. The name Hydra comes from its ability to run multiple similar jobs - much like a Hydra with multiple heads.

The basic functionalities are intuitive: it is enough to change the configuration files in conf/* accordingly to your preferences. Everything will be logged in wandb automatically.

Consider creating new root configurations conf/myawesomeexp.yaml instead of always using the default conf/default.yaml.

Sweeps

You can easily perform hyperparameters sweeps, which override the configuration defined in /conf/*.

The easiest one is the grid-search. It executes the code with every possible combinations of the specified hyperparameters:

PYTHONPATH=. python src/run.py -m optim.optimizer.lr=0.02,0.002,0.0002 optim.lr_scheduler.T_mult=1,2 optim.optimizer.weight_decay=0,1e-5

You can explore aggregate statistics or compare and analyze each run in the W&B dashboard.


We recommend to go through at least the Basic Tutorial, and the docs about Instantiating objects with Hydra.

PyTorch Lightning

Lightning makes coding complex networks simple. It is not a high level framework like keras, but forces a neat code organization and encapsulation.

You should be somewhat familiar with PyTorch and PyTorch Lightning before using this template.

Environment Variables

System specific variables (e.g. absolute paths to datasets) should not be under version control, otherwise there will be conflicts between different users.

The best way to handle system specific variables is through environment variables.

You can define new environment variables in a .env file in the project root. A copy of this file (e.g. .env.template) can be under version control to ease new project configurations.

To define a new variable write inside .env:

export MY_VAR=/home/user/my_system_path

You can dynamically resolve the variable name from Python code with:

get_env('MY_VAR')

and in the Hydra .yaml configuration files with:

${env:MY_VAR}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].