-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
22 lines (17 loc) · 804 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os,json
import torch
from configs import EXP_CONFIGS
def save_params(configs, time_data):
with open(os.path.join(configs['current_path'], 'training_data', '{}.json'.format(time_data)), 'w') as fp:
json.dump(configs, fp, indent=2)
def load_params(configs, file_name):
''' replay_name from flags.replay_name '''
with open(os.path.join(configs['current_path'], 'training_data', '{}.json'.format(file_name)), 'r') as fp:
configs = json.load(fp)
return configs
def update_tensorboard(writer,epoch,env,agent,arrived_vehicles):
env.update_tensorboard(writer,epoch)
agent.update_tensorboard(writer,epoch)
writer.add_scalar('episode/arrived_num', arrived_vehicles,
EXP_CONFIGS['max_steps']*epoch) # 1 epoch마다
writer.flush()