Merge pull request #44 from kinoai/dev

Dev
This commit is contained in:
hobogalaxy authored and GitHub committed 2020-12-07 01:08:57 +01:00
commit 699b4d2044
4 files changed
+10 -8

No files matched your search

+5 -5
View File
@@ -39,15 +39,15 @@ The directory structure of new project looks like this:
│ ├── data_modules <- All your data modules should be located here!
│ │ ├── example_datamodule <- Each datamodule should be located in separate folder!
│ │ │ ├── datamodule.py <- Contains 'DataModule' class
│ │ │ ├── datasets.py <- Contains pytorch 'Dataset' classes
│ │ │ └── transforms.py <- Contains data transformations
│ │ │ ├── datasets.py <- Contains pytorch 'Dataset' classes (optional file)
│ │ │ └── transforms.py <- Contains data transformations (optional file)
│ │ ├── ...
│ │ └── ...
│ │
│ ├── models <- All your models should be located here!
│ │ ├── example_model <- Each model should be located in separate folder!
│ │ │ ├── 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 activate your_env_name
# optionally install project with setup.py
# optionally install project as package with setup.py
pip install -e .
# 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
```yaml
# set project and enity names in project/project_config.yaml
# set project and entity names in project/project_config.yaml
loggers:
wandb:
project: "your_project_name"
@@ -18,7 +18,9 @@ class DataModule(pl.LightningDataModule):
def __init__(self, hparams):
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.train_val_split_ratio = hparams.get("train_val_split_ratio") or 0.9
self.num_workers = hparams.get("num_workers") or 1
+1
View File
@@ -26,6 +26,7 @@ def main(project_config_path, run_configs_path):
for key in run_configs[conf_name][section]:
print(" " + key + ":", run_configs[conf_name][section][key])
print()
train(project_config=project_config, run_config=run_configs[conf_name], use_wandb=True)
wandb.finish()
+1 -2
View File
@@ -16,8 +16,7 @@ def init_lit_model(hparams: dict) -> pl.LightningModule:
def init_data_module(hparams: dict) -> pl.LightningDataModule:
"""Load DataModule from folder specified in run config."""
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.prepare_data()
datamodule.setup()