From 14b66bfb16aa11d55ba671f2ab2eccdb37663d07 Mon Sep 17 00:00:00 2001 From: JohnJim0816 Date: Wed, 31 Mar 2021 18:21:57 +0800 Subject: [PATCH] update --- codes/QLearning/main.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/codes/QLearning/main.py b/codes/QLearning/main.py index bf03ce9..a6f7dac 100644 --- a/codes/QLearning/main.py +++ b/codes/QLearning/main.py @@ -5,13 +5,16 @@ Author: John Email: johnjim0816@gmail.com Date: 2020-09-11 23:03:00 LastEditor: John -LastEditTime: 2021-03-26 17:16:07 +LastEditTime: 2021-03-31 18:21:00 Discription: Environment: ''' import sys,os -sys.path.append(os.getcwd()) # 添加当前终端路径 +curr_path = os.path.dirname(__file__) +parent_path=os.path.dirname(curr_path) +sys.path.append(parent_path) # add current terminal path to sys.path + import gym import datetime @@ -20,16 +23,16 @@ from QLearning.agent import QLearning from common.plot import plot_rewards from common.utils import save_results -SEQUENCE = datetime.datetime.now().strftime("%Y%m%d-%H%M%S") # 获取当前时间 -SAVED_MODEL_PATH = os.path.split(os.path.abspath(__file__))[0]+"/saved_model/"+SEQUENCE+'/' # 生成保存的模型路径 -if not os.path.exists(os.path.split(os.path.abspath(__file__))[0]+"/saved_model/"): # 检测是否存在文件夹 - os.mkdir(os.path.split(os.path.abspath(__file__))[0]+"/saved_model/") -if not os.path.exists(SAVED_MODEL_PATH): # 检测是否存在文件夹 +SEQUENCE = datetime.datetime.now().strftime("%Y%m%d-%H%M%S") # obtain current time +SAVED_MODEL_PATH = curr_path+"/saved_model/"+SEQUENCE+'/' # path to save model +if not os.path.exists(curr_path+"/saved_model/"): + os.mkdir(curr_path+"/saved_model/") +if not os.path.exists(SAVED_MODEL_PATH): os.mkdir(SAVED_MODEL_PATH) -RESULT_PATH = os.path.split(os.path.abspath(__file__))[0]+"/results/"+SEQUENCE+'/' # 存储reward的路径 -if not os.path.exists(os.path.split(os.path.abspath(__file__))[0]+"/results/"): # 检测是否存在文件夹 - os.mkdir(os.path.split(os.path.abspath(__file__))[0]+"/results/") -if not os.path.exists(RESULT_PATH): # 检测是否存在文件夹 +RESULT_PATH = curr_path+"/results/"+SEQUENCE+'/' # path to save rewards +if not os.path.exists(curr_path+"/results/"): + os.mkdir(curr_path+"/results/") +if not os.path.exists(RESULT_PATH): os.mkdir(RESULT_PATH) class QlearningConfig: