def main(): parser = argparse.ArgumentParser() parser.add_argument('-e', '--exp_name', default="acacia") parser.add_argument('-m', '--mode', default=None) parser.add_argument('-image_path', '--image_path', default=None) parser.add_argument('-model_path', '--model_path', default=None) parser.add_argument('-model_name', '--model_name', default=None) parser.add_argument( '-r', '--reset', action="store_const", const=True, default=False, help="If set, a new model will be created, overwriting any previous version.") args = parser.parse_args() dataset_name, model_name, metric_name = experiments.get_experiment( args.exp_name) # Paths name = "{}_{}".format(dataset_name, model_name) # Train checkpoint file path_model = "checkpoints/best_model_{}.pth".format(name) path_opt = "checkpoints/opt_{}.pth".format(name) path_best_model = "checkpoints/best_model_save_{}.pth".format(name) path_history = "checkpoints/history_{}.json".format(name) if args.image_path is not None: applyOnImage.apply(args.image_path, args.model_name, args.model_path) elif args.mode == "train": train.train( dataset_name, model_name, metric_name, path_history, path_model, path_opt, path_best_model, args.reset) elif args.mode == "test": test.test( dataset_name, model_name, metric_name, path_history, path_model) elif args.mode == "summary": summary.summary(dataset_name, model_name, path_history)
def __init__(self, env_seed, env_name='', deltas=None, delta_std=0.02): self.env = gym.make(env_name) self.env.seed(0) self.params = {} self.params['env_name'] = env_name self.params['ob_dim'] = self.env.observation_space.shape[0] self.params['ac_dim'] = self.env.action_space.shape[0] self.params = get_experiment(self.params) self.params['zeros'] = True self.params['seed'] = 0 self.deltas = SharedNoiseTable(deltas, env_seed + 7) self.delta_std = delta_std
def main(): parser = argparse.ArgumentParser() ## Env setup parser.add_argument('--env_name', type=str, default='point-v0') parser.add_argument('--num_agents', '-na', type=int, default=5) parser.add_argument('--seed', '-sd', type=int, default=0) parser.add_argument('--max_iter', '-it', type=int, default=2000) parser.add_argument('--policy', '-po', type=str, default='FC') parser.add_argument('--embedding', '-em', type=str, default='a_s') parser.add_argument('--num_workers', '-nw', type=int, default=4) parser.add_argument('--filename', '-f', type=str, default='') parser.add_argument('--num_evals', '-ne', type=int, default=0) parser.add_argument('--flush', '-fl', type=int, default=1000) # may need this. it resets ray, because sometimes it fills the memory. parser.add_argument('--ob_filter', '-ob', type=str, default='MeanStdFilter') # 'NoFilter' parser.add_argument('--w_nov', '-wn', type=float, default=-1) # if negative it uses the adaptive method, else it will be fixed at the value you pick (0,1). Note that if you pick 1 itll be unsupervised (ie no reward) parser.add_argument('--dpp_kernel', '-ke', type=str, default='rbf') parser.add_argument('--states', '-ss', type=str, default='random-20') # 'random-X' X is how many parser.add_argument('--update_states', '-us', type=int, default=20) # how often to update.. we only used 20 args = parser.parse_args() params = vars(args) params = get_experiment(params) ray.init() os.environ['RAY_USE_NEW_GCS'] = 'True' state_word = [str(params['states'].split('-')[0]) if params['w_nov'] > 0 else ''][0] params['dir'] = params['env_name'] + '_Net' + str(params['layers']) + 'x' + str(params['h_dim']) + '_Agents' + str(params['num_agents']) + '_Novelty' + str(params['w_nov']) + state_word + 'kernel_' + params['dpp_kernel'] + '_lr' + str(params['learning_rate']) + '_' + params['filename'] + params['ob_filter'] if not(os.path.exists('data/'+params['dir'])): os.makedirs('data/'+params['dir']) os.makedirs('data/'+params['dir']+'/weights') os.makedirs('data/'+params['dir']+'/results') train(params)
def main(): parser = argparse.ArgumentParser() parser.add_argument('--env_name', type=str, default='Swimmer-v2') parser.add_argument('--seed', '-sd', type=int, default=0) parser.add_argument('--max_iter', '-it', type=int, default=200) parser.add_argument('--num_workers', '-nw', type=int, default=4) parser.add_argument('--filename', '-f', type=str, default='') # anything else you want to add args = parser.parse_args() params = vars(args) params = get_experiment(params) params['dir'] = params['env_name'] + '_' + params['filename'] if not(os.path.exists('data/'+params['dir'])): os.makedirs('data/'+params['dir']) os.makedirs('data/'+params['dir']+'/results') ray.init() train(params)
if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('-e', '--exp') parser.add_argument('-m', '--mode') parser.add_argument('-r', '--reset', default=0, type=int) parser.add_argument('-c', '--cut', default=None, type=int) parser.add_argument('-dList', '--dList', default=None, type=str, nargs="+") parser.add_argument('-mList', '--mList', default=None, type=str, nargs="+") parser.add_argument('-eList', '--eList', default=None, type=int, nargs="+") parser.add_argument('-lList', '--lList', default=None, nargs="+") parser.add_argument('-sList', '--sList', default=None, type=str, nargs="+") args = parser.parse_args() dList, mList, eList, lList, sList = experiments.get_experiment( args.exp, args) mList.sort() sList.sort() create_plot = False results = {} for d, m, e, l, s in product(dList, mList, eList, lList, sList): history = ut.load_history(d, m, l, e, s, args.reset) if args.mode == "train": if len(history["loss"]) == 0 or args.reset: train.train(dataset_name=d, model_name=m, epochs=e, learning_rate=l, sampling_method=s,
def main(): # SET SEED np.random.seed(1) torch.manual_seed(1) torch.cuda.manual_seed_all(1) # SEE IF CUDA IS AVAILABLE #print("STARTING - CUDA: %s" % torch.cuda.is_available()) assert torch.cuda.is_available() print("CUDA: %s" % torch.version.cuda) print("Pytroch: %s" % torch.__version__) parser = argparse.ArgumentParser() parser.add_argument('-e', '--exp') parser.add_argument('-b', '--borgy', default=0, type=int) parser.add_argument('-br', '--borgy_running', default=0, type=int) parser.add_argument('-m', '--mode', default="summary") parser.add_argument('-r', '--reset', default="None") parser.add_argument('-g', '--gpu', type=int) parser.add_argument('-c', '--configList', nargs="+", default=None) parser.add_argument('-l', '--lossList', nargs="+", default=None) parser.add_argument('-d', '--datasetList', nargs="+", default=None) parser.add_argument('-metric', '--metricList', nargs="+", default=None) args = parser.parse_args() mu.set_gpu(args.gpu) mode = args.mode exp_dict = experiments.get_experiment(args.exp) if args.configList is None: configList = exp_dict["configList"] else: configList = args.configList if args.metricList is None: metricList = exp_dict["metricList"] else: metricList = args.metricList if args.datasetList is None: datasetList = exp_dict["datasetList"] else: datasetList = args.datasetList epochs = exp_dict["epochs"] if args.lossList is None: lossList = exp_dict["lossList"] else: lossList = args.lossList # vis.close(env="loss") # vis.close(env="plots") results = {} for config, metric, dataset, loss_name in product(configList, metricList, datasetList, lossList): argList = mu.get_argList(mode, dataset, config, args.reset, epochs, metric, loss_name) main_dict = mu.argList2main_dict(main_parser.get_parser(), argList) key = ("%s - %s" % (config, loss_name), "%s_(%s)" % (dataset, metric)) if mode == "summary": results[key] = mu.summary(argList, main_dict, which="train") # TRAIN CASES if mode == "debug": debug.debug(main_dict) if mode == "train": train.main(main_dict) # TEST CASES if mode == "test": print(main_dict["dataset_name"]) cm = test.test(main_dict) print(cm) print(ut.dict2frame(results))