forked from Sentdex/SC2RL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
load-train-mlpp.py
49 lines (37 loc) · 1.08 KB
/
load-train-mlpp.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
# $ source ~/Desktop/sc2env/bin/activate
# so this works, so far.
from stable_baselines3 import PPO
import os
from sc2env import Sc2Env
import time
from wandb.integration.sb3 import WandbCallback
import wandb
LOAD_MODEL = "models/1647915989/1647915989.zip"
# Environment:
env = Sc2Env()
# load the model:
model = PPO.load(LOAD_MODEL, env=env)
model_name = f"{int(time.time())}"
models_dir = f"models/{model_name}/"
logdir = f"logs/{model_name}/"
conf_dict = {"Model": "load-v16s",
"Machine": "Puget/Desktop/v18/2",
"policy":"MlpPolicy",
"model_save_name": model_name,
"load_model": LOAD_MODEL
}
run = wandb.init(
project=f'SC2RLv6',
entity="sentdex",
config=conf_dict,
sync_tensorboard=True, # auto-upload sb3's tensorboard metrics
save_code=True, # save source code
)
# further train:
TIMESTEPS = 10000
iters = 0
while True:
print("On iteration: ", iters)
iters += 1
model.learn(total_timesteps=TIMESTEPS, reset_num_timesteps=False, tb_log_name=f"PPO")
model.save(f"{models_dir}/{TIMESTEPS*iters}")