-
Notifications
You must be signed in to change notification settings - Fork 0
/
alg_parameters.py
74 lines (52 loc) · 2 KB
/
alg_parameters.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
from datetime import datetime
""" Hyperparameters of Priority Learning!"""
class EnvParam:
N_AGENTS = 128 # number of agents used in training
WORLD_SIZE = (32, 32)
OBSTACLE_PROB = (0.2, 0.21)
class TrainParam:
lr = 3e-4
GAMMA = 0.95 # discount factor
max_grad_norm = 1
N_ENVS = 32 # number of processes
max_steps = int(3e7) # maximum number of time steps used in training
N_STEPS =EnvParam.N_AGENTS * 4 # number of time steps per process per data collection
MAX_EPISODE_LEN = int(500) # make sure bigger than n_agents
LOG_PERIOD = N_ENVS*N_STEPS*10 # per epoch
SAVE_PERIOD = N_ENVS*N_STEPS*40 # per epoch
CRITIC_MAX_VALUE = 1
UPDATE_EPOCH = 1
# specify the training algorithm
# reinforce, ppo.
ALGORITHM = "reinforce"
baseline = None # old policy, expert
# ppo algorithm
EPS_CLIP = 0.2
demo_weight = 0
rl_weight = 1
entropy_weight = 0.1
load_pretrain = False
pretrain_path = "./PPO_preTrained/MapfSippsEnv/PPO_MapfSippsEnv_0_59.pth"
class NetParameters:
EMBEDDING_DIM = 128
N_ENCODER_LAYERS = 1 # number of computation block
N_HEAD = 8
checkpoint_encoder = False
class SetupParameters:
SEED = 1234
USE_GPU_SAMPLE = False
USE_GPU_TRAIN = True
NUM_GPU = 1
all_args = {'N_AGENTS': EnvParam.N_AGENTS,
'WORLD_SIZE': EnvParam.WORLD_SIZE,
'OBSTACLE_PROB': EnvParam.OBSTACLE_PROB,
'lr': TrainParam.lr, 'GAMMA': TrainParam.GAMMA,
'MAX_GRAD_NORM': TrainParam.max_grad_norm,
'N_ENVS': TrainParam.N_ENVS,
'N_MAX_STEPS': TrainParam.max_steps,
'N_STEPS': TrainParam.N_STEPS,
'N_LAYERS': NetParameters.N_ENCODER_LAYERS,
'N_HEAD': NetParameters.N_HEAD,
'SEED': SetupParameters.SEED, 'USE_GPU_LOCAL': SetupParameters.USE_GPU_SAMPLE,
'USE_GPU_GLOBAL': SetupParameters.USE_GPU_TRAIN,
'NUM_GPU': SetupParameters.NUM_GPU}