-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq_learning.py
71 lines (66 loc) · 1.48 KB
/
q_learning.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
60
61
62
63
64
65
66
67
68
69
70
71
import argparse
import os
import sys
import time
from qlearn import train, test
if __name__ == '__main__':
argparser = argparse.ArgumentParser(description=__doc__)
argparser.add_argument(
'--mode',
default='train',
type=str
)
argparser.add_argument(
'--env-name',
default='FourLargeRooms',
type=str
)
argparser.add_argument(
'--alpha',
default=0.2,
type=float
)
argparser.add_argument(
'--epsilon',
default=0.1,
type=float
)
argparser.add_argument(
'--discount',
default=0.99,
type=float
)
argparser.add_argument(
'--num-iters',
default=1000,
type=int
)
argparser.add_argument(
'--num-seeds',
default=10,
type=int
)
argparser.add_argument(
'--policy-dir',
default='saved_qvalues/optimal_qvalues',
type=str
)
argparser.add_argument(
'-ma', '--match-action',
action='store_true',
dest='debug',
help='Match actions with ground truths and generate plots'
)
argparser.add_argument(
'-v', '--verbose',
action='store_true',
dest='debug',
help='print debug information')
args = argparser.parse_args()
start = time.time()
if args.mode == 'train':
train.train(args)
else:
test.test(args)
end = time.time()
print ("Time taken: ", end - start)