在尝试设置wandb时,我遇到以下错误:
wandb: WARNING Calling wandb.login() after wandb.init() has no effect.
2021-07-23 19:19:32,639 - wandb.wandb_agent - INFO - Running runs: []
2021-07-23 19:19:32,824 - wandb.wandb_agent - INFO - Agent received command: run
2021-07-23 19:19:32,825 - wandb.wandb_agent - INFO - Agent starting run with config:
lr: 0.01
optimizer: Adam
2021-07-23 19:19:32,826 - wandb.wandb_agent - INFO - About to run command: /usr/bin/env python --lr=0.01 --optimizer=Adam
/home/ubuntu/anaconda3/envs/pytorch_latest_p37/bin/python: can't find '__main__' module in ''
2021-07-23 19:19:37,945 - wandb.wandb_agent - INFO - Running runs: ['e8ff7j11']
2021-07-23 19:19:37,946 - wandb.wandb_agent - INFO - Cleaning up finished run: e8ff7j11
------4 more runs for different hyperparamters-------
2021-07-23 19:19:59,139 - wandb.wandb_agent - ERROR - Detected 5 failed runs in a row, shutting down.
2021-07-23 19:19:59,139 - wandb.wandb_agent - INFO - To change this value set WANDB_AGENT_MAX_INITIAL_FAILURES=val
wandb: Terminating and syncing runs. Press ctrl-c to kill.
代码:
base_config.py
class base_config:
def __init__(self):
self.epochs = 10
self.sweep_config = {
'method': 'grid',
'metric': {
'name': 'val_F1@M',
'goal': 'maximize'
},
'parameters': {
'lr': {
'values': [1e-2, 1e-3, 1e-4]
},
'optimizer': {
'values': ['Adam', 'SM3']
},
}
}
self.config_defaults = {
'lr': 1e-2,
'optimizer': 'Adam',
}
train.py
import wandb
def run(args, config):
# wandb.log()
def run_and_collect_results(args, config):
wandb.init(config=config['config_defaults'])
config.update({k: v for k, v in wandb.config.items()})
run(args, config)
if __name__ == '__main__':
# load config from config file
# load args
sweep_id = wandb.sweep(config['sweep_config'], project="Pytorch-sweeps")
wandb.agent(sweep_id, run_and_collect_results(args, config))
我不确定编写agent
for的正确方法是什么wandb
。当前代码以日志结尾,例如python --lr=0.01 --optimizer=Adam
. 文件名似乎不见了。在那种情况下,我需要写wandb.agent
一个单独的文件还是使用 CLI 界面?我期待为不同的超参数wandb.agent
调用函数的行为run_and_collect_results
。