-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
48 lines (42 loc) · 1.5 KB
/
Copy pathtest.py
File metadata and controls
48 lines (42 loc) · 1.5 KB
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
import numpy as np
from config.options import get_options
from agent import Agent
from tqdm import trange
from model.config import build_conf
if __name__ == '__main__':
args = get_options()
epochs = args.epoch
steps = args.step
save_freq = args.save_frequency
save_dir = args.full_saving_path
batch_size = args.batch_size
agent_conf = build_conf(args)
agent_conf['memory']['capacity'] = 100000
agent = Agent(agent_conf)
epsilon = 1
# We fill the memory in the while loop
for w in trange(6, desc="Warmup"):
agent.memory.reduce(100000)
while not agent.memory.full_once:
agent.run_episode(epsilon)
for step in trange(600, desc="Step", leave=False):
agent.training_step(1024)
agent.validate()
agent.memory.reduce(20000)
while not agent.memory.full_once:
agent.run_episode(epsilon)
for epoch in trange(epochs, desc="Epoch"):
epsilon = agent.random_exploration_prob(epoch * args.step)
playing_nbr, max_steps = 1, None
for k in trange(playing_nbr, desc="Playing"):
agent.run_episode(epsilon, max_steps=max_steps)
# agent.print_memory()
# Train predictor and save every save_freq epochs
for step in trange(2, desc="Step", leave=False):
agent.training_step(512)
f_measures = []
durations = []
if epoch % 20 == 0:
agent.validate()
if (epoch % save_freq) == 0:
agent.save_pred(save_dir, epoch)