Merge pull request #43 from kinoai/dev
add file for executing many runs
This commit is contained in:
6 files changed
+55
-2
No files matched your search
@@ -31,6 +31,7 @@ The directory structure of new project looks like this:
|
||||
│ ├── utils <- Different utilities
|
||||
│ │ ├── callbacks.py <- Useful training callbacks
|
||||
│ │ ├── execute_sweep.py <- Special file for executing Weights&Biases sweeps
|
||||
│ │ ├── execute_all_runs.py <- Special file for executing all specified runs one after the other
|
||||
│ │ ├── init_utils.py <- Useful initializers
|
||||
│ │ └── predict_example.py <- Example of inference with trained model
|
||||
│ │
|
||||
|
||||
@@ -50,5 +50,5 @@ MNIST_CLASSIFIER_V2:
|
||||
tags: ["v2", "uwu"]
|
||||
notes: "This is example run."
|
||||
resume_training:
|
||||
checkpoint_path: "logs/checkpoints/7ab26xr/last.ckpt"
|
||||
wandb_run_id: "7ab26xrj"
|
||||
checkpoint_path: None
|
||||
wandb_run_id: None
|
||||
@@ -100,6 +100,14 @@ def main(run_config_name: str, use_wandb: bool):
|
||||
project_config: dict = load_config("project_config.yaml")
|
||||
run_config: dict = load_config("run_configs.yaml")[run_config_name]
|
||||
|
||||
# Print run config info
|
||||
print("EXECUTING RUN:", run_config_name)
|
||||
print("CONFIG:")
|
||||
for section in run_config:
|
||||
print(" " + section + ":")
|
||||
for key in run_config[section]:
|
||||
print(" " + key + ":", run_config[section][key])
|
||||
|
||||
# Train model
|
||||
train(project_config=project_config, run_config=run_config, use_wandb=use_wandb)
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# THIS FILE WILL EXECUTE ALL RUNS SPECIFIED IN run_configs.yaml ONE AFTER THE OTHER
|
||||
# YOU CAN ALSO SPECIFY PATH TO DIFFERENT FILE WITH RUN CONFIGS
|
||||
|
||||
from argparse import ArgumentParser
|
||||
from train import train
|
||||
import wandb
|
||||
import yaml
|
||||
import os
|
||||
|
||||
|
||||
def main(project_config_path, run_configs_path):
|
||||
|
||||
with open(project_config_path, "r") as ymlfile:
|
||||
project_config = yaml.load(ymlfile, Loader=yaml.FullLoader)
|
||||
|
||||
with open(run_configs_path, "r") as ymlfile:
|
||||
run_configs = yaml.load(ymlfile, Loader=yaml.FullLoader)
|
||||
|
||||
# EXECUTE ALL RUNS ONE AFTER THE OTHER
|
||||
for conf_name in run_configs:
|
||||
print()
|
||||
print("EXECUTING RUN:", conf_name)
|
||||
print("CONFIG:")
|
||||
for section in run_configs[conf_name]:
|
||||
print(" " + section + ":")
|
||||
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()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument("-p", "--project_config_path", type=str,
|
||||
default=os.path.join(os.path.dirname(os.path.dirname(__file__)), "project_config.yaml"))
|
||||
parser.add_argument("-r", "--run_configs_path", type=str,
|
||||
default=os.path.join(os.path.dirname(os.path.dirname(__file__)), "run_configs.yaml"))
|
||||
args = parser.parse_args()
|
||||
|
||||
main(project_config_path=args.project_config_path, run_configs_path=args.run_configs_path)
|
||||
@@ -1,5 +1,6 @@
|
||||
# THIS FILE IS FOR HYPERPARAMETER SEARCH WITH Weights&Biases
|
||||
# IT SHOULDN't BE EXECUTED DIRECTLY, IT SHOULD BE RUN BY WANDB SWEEP AGENT!
|
||||
|
||||
import wandb
|
||||
import train
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ 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")
|
||||
datamodule = importlib.import_module(module_path).DataModule(hparams=hparams)
|
||||
datamodule.prepare_data()
|
||||
datamodule.setup()
|
||||
|
||||
Reference in new issue
Block a user