-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
65 lines (55 loc) · 1.83 KB
/
config.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
import yaml
# import functools as f
# import hashlib
class JobConfig:
def __init__(self, filename=None):
if filename:
self.from_filename(filename)
else:
self.random_seed = None
self.buffer_size = None
self.batch_size = None
self.gamma = None
self.tau = None
self.lr_actor = None
self.lr_critic = None
self.weight_decay = None
self.sigma = None
self.actor_nn_size = None
self.critic_nn_size = None
self.batch_norm = None
self.clip_grad_norm = None
self.n_episodes = None
self.score_window_size = None
self.print_every = None
self.max_score = None
self.damp_exploration_noise = None
self.n_episodes = None
self.score_window_size = None
self.print_every = None
self.max_score = None
self.damp_exploration_noise = None
self.render_game = None
def __hash__(self):
return hash(repr(sorted(self.__dict__.items())))
def __eq__(self, other):
return self.__dict__ == other.__dict__
def from_filename(self, filename):
"Initialize from a file"
with open(filename, 'r') as f:
obj = yaml.load(f)
self.__dict__ = obj.__dict__
def dump(self, filename):
with open(filename, "w") as f:
yaml.dump(self, f)
class MetaConfig:
def __init__(self, filename):
self.from_filename(filename)
def from_filename(self, filename):
"Initialize from a file"
with open(filename, 'r') as f:
obj = yaml.load(f)
self.__dict__ = obj.__dict__
def dump(self, filename):
with open(filename, "w") as f:
yaml.dump(self, f)