-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprompt_learning_comde.py
39 lines (26 loc) · 1.19 KB
/
prompt_learning_comde.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
from jax.config import config
config.update("jax_debug_nans", True)
import random
from typing import Dict, Union
random.seed(7)
import hydra
from hydra.utils import instantiate
from omegaconf import DictConfig, OmegaConf
from comde.rl.envs.metaworld.multistage_metaworld import MultiStageMetaWorld
from comde.rl.envs.franka_kitchen.franka_kitchen import FrankaKitchen
from comde.rl.envs.rlbench.rlbench import RLBench
from comde.trainer.prompt_trainer import PromptTrainer
@hydra.main(version_base=None, config_path="config/train", config_name="comde_base.yaml")
def program(cfg: DictConfig) -> None:
cfg = OmegaConf.to_container(cfg, resolve=True) # type: Dict[str, Union[str, int, Dict]]
assert cfg["mode"]["mode"] == "prompt_learning", \
f"Your mode is {cfg['mode']['mode']}. " \
"Please add 'mode=prompt_learning' to your command line if you want to train prompt learning"
prompt_cfg = cfg["mode"]
envs = [MultiStageMetaWorld, FrankaKitchen, RLBench]
prompt_learner = instantiate(cfg["prompt_learner"])
prompt_trainer = PromptTrainer(cfg=cfg, envs=envs, prompt_learner=prompt_learner)
for _ in range(prompt_cfg["max_iter"]):
prompt_trainer.run()
if __name__ == "__main__":
program()