# Parametros globales manager = ParamsManager(args.params_file) agent_params = manager.get_agent_params() global_step_num = 0 #Fichero del log summary_filename_prefix = agent_params['summary_filename_prefix'] summary_filename = summary_filename_prefix + args.env + datetime.now( ).strftime("%y-%m-%d-%H-%M") # Sumary writter de TBX writer = SummaryWriter(summary_filename) manager.export_agent_params(summary_filename + "/" + "agent_params.json") manager.export_env_params(summary_filename + "/" + "env_params.json") # Habilitar entranamiento por GPU use_cuda = agent_params['use_cuda'] device = torch.device( "cuda:" + str(args.gpu_id) if torch.cuda.is_available() and use_cuda else "cpu") # Hbilitar la semilla aleotoria seed = agent_params['seed'] torch.manual_seed(seed) np.random.seed(seed) if torch.cuda.is_available() and use_cuda: torch.cuda.manual_seed_all(seed)
help="GPU device ID to use. Default:0", type=int, default=0, metavar="GPU_ID") args = parser.parse_args() global_step_num = 0 params_manager = ParamsManager(args.params_file) agent_algo = "A2C" summary_file_path_prefix = params_manager.get_agent_params( )['summary_file_path_prefix'] summary_file_path = summary_file_path_prefix + agent_algo + '_' + args.env + "_" + datetime.now( ).strftime("%y-%m-%d-%H-%M") writer = SummaryWriter(summary_file_path) # Export the parameters as json files to the log directory to keep track of the parameters used in each experiment params_manager.export_env_params(summary_file_path + "/" + "env_params.json") params_manager.export_agent_params(summary_file_path + "/" + "agent_params.json") use_cuda = params_manager.get_agent_params()['use_cuda'] # Introduced in PyTorch 0.4 device = torch.device( "cuda:" + str(args.gpu_id) if torch.cuda.is_available() and use_cuda else "cpu") seed = params_manager.get_agent_params()[ 'seed'] # With the intent to make the results reproducible torch.manual_seed(seed) np.random.seed(seed) if torch.cuda.is_available() and use_cuda: torch.cuda.manual_seed_all(seed)
args = args.parse_args() # Parameter Manager params_manager = ParamsManager(args.params_file) seed = params_manager.get_agent_params()['seed'] summary_file_path_prefix = params_manager.get_agent_params( )['summary_file_path_prefix'] summary_file_path = summary_file_path_prefix + args.env + \ '_' + datetime.now().strftime('%y-%m-%d-%H-%M') if not exists(summary_file_path): makedirs(summary_file_path) writer = SummaryWriter(summary_file_path) params_manager.export_env_params(join(summary_file_path, 'env_params.json')) params_manager.export_agent_params(join(summary_file_path, 'agent_params.json')) global_step_num = 0 # GPU Setting use_cuda = params_manager.get_agent_params()['use_cuda'] device = torch.device( 'cuda:' + str(args.gpu_id) if torch.cuda.is_available() and use_cuda else 'cpu') torch.manual_seed(seed) np.random.seed(seed) if torch.cuda.is_available() and use_cuda: torch.cuda.manual_seed_all(seed)