-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.py
110 lines (79 loc) · 2.09 KB
/
configuration.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
from baseline.utils import jsonParser, writeTrainInfo
from baseline.utils import setup_logger
from datetime import datetime, timedelta
import logging
import os
import torch
import math
_path_ = "./cfg/ape_x.json"
# _path_ = "./cfg/impala.json"
# _path_ = './cfg/r2d2.json'
_total_ALG=['IMPALA', 'R2D2', 'APE_X']
if not os.path.isdir('./log'):
os.mkdir('./log')
for t in _total_ALG:
os.mkdir(
os.path.join(
'./log', t
)
)
if not os.path.isdir('./weight'):
os.mkdir('./weight')
for t in _total_ALG:
os.mkdir(
os.path.join(
'./weight', t
)
)
_parser_ = jsonParser(_path_)
_data_ = _parser_.loadParser()
ALG = _data_['ALG']
DATA = _data_
# APE_X
if ALG == "APE_X":
USE_REWARD_CLIP = _data_["USE_REWARD_CLIP"]
BASE_PATH = "./log/APE_X"
# R2D2
elif ALG == "R2D2":
FIXED_TRAJECTORY = _data_["FIXED_TRAJECTORY"]
MEM = _data_["MEM"]
USE_RESCALING = _data_["USE_RESCALING"]
BASE_PATH = "./log/R2D2"
elif ALG == "IMPALA":
C_LAMBDA = _data_["C_LAMBDA"]
C_VALUE = _data_["C_VALUE"]
P_VALUE = _data_["P_VALUE"]
ENTROPY_R = _data_["ENTROPY_R"]
BASE_PATH = ',/log/IMPALA'
# COMMOLN
use_per = ALG != "IMPALA"
if use_per:
ALPHA = _data_['ALPHA']
BETA = _data_['BETA']
TARGET_FREQUENCY = _data_['TARGET_FREQUENCY']
N = _data_['N']
GAMMA = _data_['GAMMA']
BATCHSIZE = _data_['BATCHSIZE']
ACTION_SIZE = _data_['ACTION_SIZE']
UNROLL_STEP = _data_['UNROLL_STEP']
REPLAY_MEMORY_LEN = _data_["REPLAY_MEMORY_LEN"]
REDIS_SERVER = _data_["REDIS_SERVER"]
try:
REDIS_SERVER_PUSH = _data_["REDIS_SERVER_PUSH"]
except:
REDIS_SERVER_PUSH = "localhost"
DEVICE = _data_["DEVICE"]
LEARNER_DEVICE = _data_["LEARNER_DEVICE"]
BUFFER_SIZE = _data_["BUFFER_SIZE"]
# MODEL & OPTIM
OPTIM_INFO = _data_["optim"]
MODEL = _data_["model"]
# SAVE and LOG PATH
_current_time_ = datetime.now()
CURRENT_TIME = _current_time_.strftime("%m_%d_%Y_%H_%M_%S")
_log_p = os.path.join(
'./log', ALG, CURRENT_TIME
)
LOG_W = os.path.join(
'./weight', ALG, CURRENT_TIME
)