-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
59 lines (51 loc) · 1.83 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
Main
-Process the yml config file
-Create an agent instance
-Run the agent
"""
from src.agents import *
from src.utils.utils import (
updated_config,
dict_print,
create_save_loc,
set_logger,
backup_code,
set_seed,
)
import wandb
if __name__ == "__main__":
# ############# handling the bash input arguments and yaml configuration file ###############
config = updated_config()
os.environ["CUDA_VISIBLE_DEVICES"] = config["CUDA_VISIBLE_DEVICES"]
# create saving location and document config files
create_save_loc(config) # config['save_dir'] gets updated here!
save_dir = config["save_dir"]
# ############# handling the logistics of (seed), and (logging) ###############
set_seed(config["train"]["seed"])
set_logger(save_dir, config["log_level"], "train", config["comment"])
backup_code(save_dir)
# printing the configuration
dict_print(config)
# ############# Wandb setup ###############
wandb.init(
project="ProtoASNet", # TODO setup project name
config=config,
name=None if config["run_name"] == "" else config["run_name"],
mode=config["wandb_mode"], # one of "online", "offline" or "disabled"
notes=config["save_dir"], # to know where the model is saved!
)
# Update config based on wandb sweep selected configs
# config = wandb.config # uncomment when using wandb sweep
# ############# agent setup ###############
# Create the Agent and pass all the configuration to it then run it.
agent_class = globals()[config["agent"]]
agent = agent_class(config)
# ############# Run the system ###############
if config["eval_only"]:
agent.evaluate(mode=config["eval_data_type"])
elif config["push_only"]:
agent.push(replace_prototypes=False)
else:
agent.run()
agent.finalize()