Write your model faster with pytorch-lightning-wadb-code-backbone
This repository provides the base code for pytorch-lightning and weight and biases simultaneous integration + hydra (to keep configs clean).
This repository shows a Toy configuration of CV classificator
│ README.md │ method.py | dataloader.py | train.py | └───models │ │ model.py | └───datasets │ │ dataset.py │ │ transformfactory.py | └───configs │ │ defaults.yaml │ └─── dataloader │ │ │ dataset.yaml │ │ │ └─── model │ │ │ model.yaml
The code is divided into a number of subpackages:
How do I use this code
The core of this repository is that the pytorch-lightning (pl) pipline is configured though .yaml file.
There are few key points of this repository:
- write your data preprocessing pipline in dataset file (see the toy dataset.py and transformfactory.py)
- write your model and pl logic in model file (see the toy model.py)
- configure your pipline through .yaml file and see all metrics in wadb
Login to your
wandb account, running once
Configure the logging in
W&B is our logger of choice, but that is a purely subjective decision. Since we are using Lightning, you can replace
wandbwith the logger you prefer (you can even build your own).
More about Lightning loggers here.
To understand the structure see hydra.
dataset.yaml and model.yaml consist of dataset_type and model_type keys respectively. Through keys values pl pipline is configured.
Write your dataset pipline (includes preprocessing through transformfactory.py). Pass dataset_type name (as a key) dataset class (as a value) into self.dataset_types dict in dataloader.py file.
Write your model pipline (includes with train step logic, see toy example). Pass model_type name (as a key) model class (as a value) into self.model_types dict in method.py file.
Configure all parameters through .yaml file with integrated wadb