update execute_sweep.py
This commit is contained in:
1 parent
8628600ea3
commit
7d09ab8ece
2 files changed
+25
-19
No files matched your search
+22
-19
@@ -1,20 +1,23 @@
|
|||||||
# import wandb
|
import wandb
|
||||||
# import train
|
import train
|
||||||
#
|
|
||||||
#
|
|
||||||
# # Load project config
|
|
||||||
# config = train.load_config()
|
|
||||||
#
|
|
||||||
# # Initialize wandb
|
|
||||||
# wandb.init()
|
|
||||||
#
|
|
||||||
# # Replace project config hyperparameters with the ones loaded from wandb sweep server
|
|
||||||
# sweep_hparams = wandb.Config._as_dict(wandb.config)
|
|
||||||
# for key, value in sweep_hparams.items():
|
|
||||||
# if key != "_wandb":
|
|
||||||
# config["hparams"][key] = value
|
|
||||||
#
|
|
||||||
# # Execute run
|
|
||||||
# train.train(config)
|
|
||||||
|
|
||||||
# TODO: this file
|
|
||||||
|
# THIS FILE SHOULDN't BE EXECUTED DIRECTLY, IT SHOULD BE RUN BY WANDB SWEEP AGENT!
|
||||||
|
|
||||||
|
# Load project config
|
||||||
|
conf = train.load_config()
|
||||||
|
|
||||||
|
# Choose model for hyperparameter search
|
||||||
|
model_conf = conf["model_configs"]["simple_mnist_classifier_v1"]
|
||||||
|
|
||||||
|
# Initialize wandb
|
||||||
|
wandb.init()
|
||||||
|
|
||||||
|
# Replace project config hyperparameters with the ones loaded from wandb sweep server
|
||||||
|
sweep_hparams = wandb.Config._as_dict(wandb.config)
|
||||||
|
for key, value in sweep_hparams.items():
|
||||||
|
if key != "_wandb" and not key.startswith("dataset/"):
|
||||||
|
model_conf[key] = value
|
||||||
|
|
||||||
|
# Execute run
|
||||||
|
train.train(config=conf, model_config=model_conf)
|
||||||
@@ -2,6 +2,7 @@ from pytorch_lightning.loggers import WandbLogger, TensorBoardLogger, CometLogge
|
|||||||
from pytorch_lightning.callbacks import ModelCheckpoint, EarlyStopping
|
from pytorch_lightning.callbacks import ModelCheckpoint, EarlyStopping
|
||||||
from lightning_modules.data_modules import datamodules, transforms
|
from lightning_modules.data_modules import datamodules, transforms
|
||||||
import importlib
|
import importlib
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
def init_lit_model(model_config):
|
def init_lit_model(model_config):
|
||||||
@@ -52,6 +53,8 @@ def init_wandb_logger(config, lit_model, datamodule):
|
|||||||
save_dir="logs/",
|
save_dir="logs/",
|
||||||
save_code=False
|
save_code=False
|
||||||
)
|
)
|
||||||
|
if not os.path.exists("logs/"):
|
||||||
|
os.mkdir("logs/")
|
||||||
wandb_logger.watch(lit_model.model, log=None)
|
wandb_logger.watch(lit_model.model, log=None)
|
||||||
wandb_logger.log_hyperparams({
|
wandb_logger.log_hyperparams({
|
||||||
"model_name": lit_model.model.__class__.__name__,
|
"model_name": lit_model.model.__class__.__name__,
|
||||||
|
|||||||
Reference in new issue
Block a user