add utils folder

This commit is contained in:
hobogalaxy committed 2021-01-13 00:44:33 +01:00
1 parent 94eaaa5072
commit b9af36fe28
6 files changed
+45 -337

No files matched your search

+42 -42
View File
@@ -1,42 +1,42 @@
# THIS FILE IS FOR HYPERPARAMETER SEARCH WITH Weights&Biases
# IT SHOULDN't BE EXECUTED DIRECTLY, IT SHOULD BE RUN BY WANDB SWEEP AGENT!
# hydra imports
from omegaconf import DictConfig
import hydra
# template utils imports
import template_utils.initializers as utils
import wandb
from train import train
# Replace run config hyperparameters with the ones loaded from wandb sweep server
def replace_hparams(config, sweep_hparams):
for key, value in sweep_hparams.items():
if key == "_wandb":
continue
elif key in config["trainer"]["args"]:
config["trainer"]["args"][key] = value
elif key in config["model"]["args"]:
config["model"]["args"][key] = value
elif key in config["optimizer"]["args"]:
config["optimizer"]["args"][key] = value
elif key in config["datamodule"]["args"]:
config["datamodule"]["args"][key] = value
@hydra.main(config_path="configs/", config_name="config.yaml")
def main(config: DictConfig) -> None:
wandb.init()
sweep_hparams = wandb.Config._as_dict(wandb.config)
utils.show_config(config) # print content of config
train(config)
wandb.finish()
if __name__ == "__main__":
main()
# # THIS FILE IS FOR HYPERPARAMETER SEARCH WITH Weights&Biases
# # IT SHOULDN't BE EXECUTED DIRECTLY, IT SHOULD BE RUN BY WANDB SWEEP AGENT!
#
# # hydra imports
# from omegaconf import DictConfig
# import hydra
#
# # template utils imports
# import src.utils.initializers as utils
#
# import wandb
# from train import train
#
#
# # Replace run config hyperparameters with the ones loaded from wandb sweep server
# def replace_hparams(config, sweep_hparams):
# for key, value in sweep_hparams.items():
# if key == "_wandb":
# continue
# elif key in config["trainer"]["args"]:
# config["trainer"]["args"][key] = value
# elif key in config["model"]["args"]:
# config["model"]["args"][key] = value
# elif key in config["optimizer"]["args"]:
# config["optimizer"]["args"][key] = value
# elif key in config["datamodule"]["args"]:
# config["datamodule"]["args"][key] = value
#
#
# @hydra.main(config_path="configs/", config_name="config.yaml")
# def main(config: DictConfig) -> None:
# wandb.init()
#
# sweep_hparams = wandb.Config._as_dict(wandb.config)
# utils.show_config(config) # print content of config
#
# train(config)
# wandb.finish()
#
#
# if __name__ == "__main__":
# main()
@@ -1 +0,0 @@
import hydra