4 files changed
+9
-7
No files matched your search
@@ -39,15 +39,15 @@ The directory structure of new project looks like this:
|
|||||||
│ ├── data_modules <- All your data modules should be located here!
|
│ ├── data_modules <- All your data modules should be located here!
|
||||||
│ │ ├── example_datamodule <- Each datamodule should be located in separate folder!
|
│ │ ├── example_datamodule <- Each datamodule should be located in separate folder!
|
||||||
│ │ │ ├── datamodule.py <- Contains 'DataModule' class
|
│ │ │ ├── datamodule.py <- Contains 'DataModule' class
|
||||||
│ │ │ ├── datasets.py <- Contains pytorch 'Dataset' classes
|
│ │ │ ├── datasets.py <- Contains pytorch 'Dataset' classes (optional file)
|
||||||
│ │ │ └── transforms.py <- Contains data transformations
|
│ │ │ └── transforms.py <- Contains data transformations (optional file)
|
||||||
│ │ ├── ...
|
│ │ ├── ...
|
||||||
│ │ └── ...
|
│ │ └── ...
|
||||||
│ │
|
│ │
|
||||||
│ ├── models <- All your models should be located here!
|
│ ├── models <- All your models should be located here!
|
||||||
│ │ ├── example_model <- Each model should be located in separate folder!
|
│ │ ├── example_model <- Each model should be located in separate folder!
|
||||||
│ │ │ ├── lightning_module.py <- Contains 'LitModel' class with train/val/test step methods
|
│ │ │ ├── lightning_module.py <- Contains 'LitModel' class with train/val/test step methods
|
||||||
│ │ │ └── models.py <- Model architectures used by lightning_module.py
|
│ │ │ └── models.py <- Model architectures used by lightning_module.py (optional file)
|
||||||
│ │ ├── ...
|
│ │ ├── ...
|
||||||
│ │ └── ...
|
│ │ └── ...
|
||||||
│ │
|
│ │
|
||||||
@@ -173,7 +173,7 @@ conda update conda
|
|||||||
conda env create -f conda_env.yaml -n your_env_name
|
conda env create -f conda_env.yaml -n your_env_name
|
||||||
conda activate your_env_name
|
conda activate your_env_name
|
||||||
|
|
||||||
# optionally install project with setup.py
|
# optionally install project as package with setup.py
|
||||||
pip install -e .
|
pip install -e .
|
||||||
|
|
||||||
# install requirements
|
# install requirements
|
||||||
@@ -190,7 +190,7 @@ python train.py --use_wandb=False --run_config MNIST_CLASSIFIER_V1
|
|||||||
|
|
||||||
Or you can train model with Weights&Biases logging
|
Or you can train model with Weights&Biases logging
|
||||||
```yaml
|
```yaml
|
||||||
# set project and enity names in project/project_config.yaml
|
# set project and entity names in project/project_config.yaml
|
||||||
loggers:
|
loggers:
|
||||||
wandb:
|
wandb:
|
||||||
project: "your_project_name"
|
project: "your_project_name"
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ class DataModule(pl.LightningDataModule):
|
|||||||
def __init__(self, hparams):
|
def __init__(self, hparams):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.data_dir = hparams.get("data_dir") or "data/mnist"
|
# hparams["data_dir"] is always automatically set to "path_to_project/data/"
|
||||||
|
self.data_dir = hparams["data_dir"]
|
||||||
|
|
||||||
self.batch_size = hparams.get("batch_size") or 64
|
self.batch_size = hparams.get("batch_size") or 64
|
||||||
self.train_val_split_ratio = hparams.get("train_val_split_ratio") or 0.9
|
self.train_val_split_ratio = hparams.get("train_val_split_ratio") or 0.9
|
||||||
self.num_workers = hparams.get("num_workers") or 1
|
self.num_workers = hparams.get("num_workers") or 1
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ def main(project_config_path, run_configs_path):
|
|||||||
for key in run_configs[conf_name][section]:
|
for key in run_configs[conf_name][section]:
|
||||||
print(" " + key + ":", run_configs[conf_name][section][key])
|
print(" " + key + ":", run_configs[conf_name][section][key])
|
||||||
print()
|
print()
|
||||||
|
|
||||||
train(project_config=project_config, run_config=run_configs[conf_name], use_wandb=True)
|
train(project_config=project_config, run_config=run_configs[conf_name], use_wandb=True)
|
||||||
wandb.finish()
|
wandb.finish()
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ def init_lit_model(hparams: dict) -> pl.LightningModule:
|
|||||||
def init_data_module(hparams: dict) -> pl.LightningDataModule:
|
def init_data_module(hparams: dict) -> pl.LightningDataModule:
|
||||||
"""Load DataModule from folder specified in run config."""
|
"""Load DataModule from folder specified in run config."""
|
||||||
module_path = "data_modules." + hparams["datamodule_folder"] + ".datamodule"
|
module_path = "data_modules." + hparams["datamodule_folder"] + ".datamodule"
|
||||||
if "data_dir" not in hparams:
|
|
||||||
hparams["data_dir"] = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data")
|
hparams["data_dir"] = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data")
|
||||||
datamodule = importlib.import_module(module_path).DataModule(hparams=hparams)
|
datamodule = importlib.import_module(module_path).DataModule(hparams=hparams)
|
||||||
datamodule.prepare_data()
|
datamodule.prepare_data()
|
||||||
|
|||||||
Reference in new issue
Block a user