#Creating the Networks and Methods of the Run. gpu_options = tf.GPUOptions( per_process_gpu_memory_fraction=settings["GPUCapacitty"], allow_growth=True) config = tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False, allow_soft_placement=True) sess = tf.Session(config=config) with tf.device(args.processor): Method = GetFunction(settings["Method"]) workers = Method(sess=sess, settings=settings, netConfigOverride=netConfigOverride) InitializeVariables( sess) #Included to catch if there are any uninitalized variables. #Saving config files in the model directory EXP_NAME = settings["RunName"] LOG_PATH = './logs/' + EXP_NAME CreatePath(LOG_PATH) with open(LOG_PATH + '/runSettings.json', 'w') as outfile: json.dump(settings, outfile) with open(LOG_PATH + '/netConfigOverride.json', 'w') as outfile: json.dump(netConfigOverride, outfile) COORD = tf.train.Coordinator() worker_threads = [] for i, worker in enumerate(workers): if i == 0: job = lambda: worker.work(COORD, render=args.render)
import tensorflow as tf import numpy as np from utils.utils import InitializeVariables, CreatePath, interval_flag, GetFunction if __name__ == "__main__": import numpy as np gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.5, allow_growth=True) config = tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False, allow_soft_placement=True) sess = tf.Session(config=config) with tf.device("/gpu:0"): test = HierarchicalNetwork(configFile="networks/hierarchyTest.json",actionSize=4) # s = tf.placeholder(tf.float32, [None,39,39,6], 'S') # state={"state":s} # out = test(state) HPs = { "eps":0.2, "EntropyBeta":0.00, "CriticBeta":0.3, "LR":0.0001, "Gamma":0.99, "lambda":0.9, "Optimizer":"Adam", "Epochs":5, "BatchSize":1024, "FS":2, "MinibatchSize":32} test2 = PPO_Hierarchy(test,sess,[10,10,3],4,HPs) InitializeVariables(sess) s = np.random.rand(10,10,10,3) a,stuff=test2.GetAction(s,0)