def __init__(self, config, quit_on_end=False): """ Initialize GPSMain Args: config: Hyperparameters for experiment quit_on_end: When true, quit automatically on completion """ self._quit_on_end = quit_on_end self._hyperparams = config self._conditions = config['common']['conditions'] if 'train_conditions' in config['common']: self._train_idx = config['common']['train_conditions'] self._test_idx = config['common']['test_conditions'] else: self._train_idx = range(self._conditions) config['common']['train_conditions'] = config['common'][ 'conditions'] self._hyperparams = config self._test_idx = self._train_idx self._data_files_dir = config['common']['data_files_dir'] self.agent = config['agent']['type'](config['agent']) self.data_logger = DataLogger() self.gui = GPSTrainingGUI( config['common']) if config['gui_on'] else None config['algorithm']['agent'] = self.agent self.algorithm = config['algorithm']['type'](config['algorithm'])
def __init__(self, config, quit_on_end=False): """ Initialize GPSMain Args: config: Hyperparameters for experiment quit_on_end: When true, quit automatically on completion """ self._quit_on_end = quit_on_end self._hyperparams = config # print(config) self._conditions = config['common']['conditions'] if 'train_conditions' in config['common']: self._train_idx = config['common']['train_conditions'] self._test_idx = config['common']['test_conditions'] else: self._train_idx = range(self._conditions) config['common']['train_conditions'] = config['common'][ 'conditions'] self._hyperparams = config self._test_idx = self._train_idx self._data_files_dir = config['common']['data_files_dir'] self.agent = config['agent']['type'](config['agent']) self.data_logger = DataLogger() self.gui = GPSTrainingGUI( config['common']) if config['gui_on'] else None config['algorithm']['agent'] = self.agent # hard code to pass the map_state and target_state config['algorithm']['cost']['costs'][1]['data_types'][3][ 'target_state'] = config['agent']['target_state'] config['algorithm']['cost']['costs'][1]['data_types'][3][ 'map_size'] = config['agent']['map_size'] # config['algorithm']['cost']['costs'][1]['data_types'][3]['map_size'] = CUT_MAP_SIZE if len(config['algorithm']['cost']['costs']) > 2: # temporarily deprecated, not considering collision cost # including cost_collision config['algorithm']['cost']['costs'][2]['data_types'][3][ 'target_state'] = config['agent']['target_state'] config['algorithm']['cost']['costs'][2]['data_types'][3][ 'map_size'] = config['agent']['map_size'] config['algorithm']['cost']['costs'][2]['data_types'][3][ 'map_state'] = config['agent']['map_state'] # print(config['algorithm']) self.algorithm = config['algorithm']['type'](config['algorithm']) # Modified by RH self.finishing_time = None self.U = None self.final_pos = None self.samples = [] self.quick_sample = None # self.map_size = config['agent']['map_size'] self.map_size = CUT_MAP_SIZE self.display_center = config['agent']['display_center']
def __init__(self, config): self._hyperparams = config self._conditions = config['common']['conditions'] self._data_files_dir = config['common']['data_files_dir'] self.agent = config['agent']['type'](config['agent']) self.data_logger = DataLogger() self.gui = GPSTrainingGUI( config['common']) if config['gui_on'] else None config['algorithm']['agent'] = self.agent self.algorithm = config['algorithm']['type'](config['algorithm'])
def __init__(self, config): """ Initialize GPSMain Args: config: Hyperparameters for experiment quit_on_end: When true, quit automatically on completion """ self._quit_on_end = quit_on_end self._hyperparams = config self._conditions = config['common']['conditions'] if 'train_conditions' in config['common']: self._train_idx = config['common']['train_conditions'] self._test_idx = config['common']['test_conditions'] else: self._train_idx = range(self._conditions) config['common']['train_conditions'] = config['common'][ 'conditions'] self._hyperparams = config self._test_idx = self._train_idx self._data_files_dir = config['common']['data_files_dir'] self.agent = config['agent']['type'](config['agent']) self.data_logger = DataLogger() self.gui = GPSTrainingGUI( config['common']) if config['gui_on'] else None config['algorithm']['agent'] = self.agent self.algorithm = config['algorithm']['type'](config['algorithm']) self.algorithm.init_samples = self._hyperparams['num_samples'] if self.algorithm._hyperparams['ioc']: demo_file = self._data_files_dir + 'demos.pkl' demos = self.data_logger.unpickle(demo_file) if demos is None: self.demo_gen = GenDemo(config) self.demo_gen.ioc_algo = self.algorithm self.demo_gen.generate() demo_file = self._data_files_dir + 'demos.pkl' demos = self.data_logger.unpickle(demo_file) config['agent']['pos_body_offset'] = demos['pos_body_offset'] self.agent = config['agent']['type'](config['agent']) self.algorithm.demoX = demos['demoX'] self.algorithm.demoU = demos['demoU'] self.algorithm.demoO = demos['demoO']
def __init__(self, config, quit_on_end=False, no_algorithm=False): """ Initialize GPSMain Args: config: Hyperparameters for experiment quit_on_end: When true, quit automatically on completion """ self._quit_on_end = quit_on_end self._hyperparams = config self._conditions = config['common']['conditions'] if 'train_conditions' in config['common']: self._train_idx = config['common']['train_conditions'] self._test_idx = config['common']['test_conditions'] else: self._train_idx = range(self._conditions) config['common']['train_conditions'] = config['common'][ 'conditions'] self._hyperparams = config self._test_idx = self._train_idx self._data_files_dir = config['common']['data_files_dir'] config['agent']['data_files_dir'] = self._data_files_dir config['algorithm']['data_files_dir'] = self._data_files_dir self.agent = config['agent']['type'](config['agent']) self.data_logger = DataLogger() self.gui = None if config['gui_on']: from gps.gui.gps_training_gui import GPSTrainingGUI # Only import if neccessary self.gui = GPSTrainingGUI(config['common']) self.mode = None config['algorithm']['agent'] = self.agent if not no_algorithm: self.algorithm = config['algorithm']['type'](config['algorithm']) self.algorithm._data_files_dir = self._data_files_dir if hasattr(self.algorithm, 'policy_opt'): self.algorithm.policy_opt._data_files_dir = self._data_files_dir self.session_id = None
def __init__(self, config, quit_on_end=False): """ Initialize GPSMain Args: config: Hyperparameters for experiment quit_on_end: When true, quit automatically on completion """ self.start_time = timeit.default_timer() self._quit_on_end = quit_on_end self._hyperparams = config self._conditions = config['common']['conditions'] if 'train_conditions' in config['common']: self._train_idx = config['common']['train_conditions'] self._test_idx = config['common']['test_conditions'] else: self._train_idx = list(range(self._conditions)) config['common']['train_conditions'] = config['common'][ 'conditions'] self._hyperparams = config self._test_idx = self._train_idx self._data_files_dir = config['common']['data_files_dir'] self.agent = config['agent']['type'](config['agent']) self.data_logger = DataLogger() self.gui = GPSTrainingGUI( config['common']) if config['gui_on'] else None config['algorithm']['agent'] = self.agent self.algorithm = config['algorithm']['type'](config['algorithm']) #CB save image of cost w/ gui if not config['gui_on']: self.simplePlotter = SimplePlotter( config['common']['experiment_name'], config['common']['data_files_dir'])
def __init__(self, config, quit_on_end=False): """ Initialize GPSMain Args: config: Hyperparameters for experiment quit_on_end: When true, quit automatically on completion """ self._quit_on_end = quit_on_end self._hyperparams = config self._conditions = config['common']['conditions'] #self._condition = 1 if 'train_conditions' in config['common']: #False self._train_idx = config['common']['train_conditions'] self._test_idx = config['common']['test_conditions'] else: self._train_idx = range(self._conditions) config['common']['train_conditions'] = config['common'][ 'conditions'] #create a new key in the dictionary common and assign the value 1 self._hyperparams = config #reinitiallizing the hyperparameters because the config was changed self._test_idx = self._train_idx #getting hte train index again self._data_files_dir = config['common']['data_files_dir'] #getting the data file path from which is stored in the common dic self.agent = config['agent']['type'](config['agent']) #here it creat the object from the agent directory #print(self.agent,'self.agent') self.data_logger = DataLogger() #here the gui files leads to the self.gui = GPSTrainingGUI( config['common']) if config['gui_on'] else None #again with they change the config file now adding object to the dic config['algorithm']['agent'] = self.agent self.algorithm = config['algorithm']['type'](config['algorithm'])
def __init__(self, config, quit_on_end=False): """ Initialize GPSMain Args: config: Hyperparameters for experiment quit_on_end: When true, quit automatically on completion """ # This controls whether there is a learned reset or not # There is a learned reset when special_reset = True try: self.special_reset = config['agent']['special_reset'] except: self.special_reset = False self._quit_on_end = quit_on_end self._hyperparams = config self._conditions = config['common']['conditions'] # There's going to be as many reset conditions as conditions self._reset_conditions = self._conditions if 'train_conditions' in config['common']: self._train_idx = config['common']['train_conditions'] self._test_idx = config['common']['test_conditions'] else: self._train_idx = range(self._conditions) config['common']['train_conditions'] = config['common'][ 'conditions'] self._hyperparams = config self._test_idx = self._train_idx self._data_files_dir = config['common']['data_files_dir'] self.agent = config['agent']['type'](config['agent']) self.data_logger = DataLogger() self.gui = GPSTrainingGUI( config['common']) if config['gui_on'] else None config['algorithm']['agent'] = self.agent self.algorithm = config['algorithm']['type'](config['algorithm']) import tensorflow as tf try: with tf.variable_scope( 'reset'): # to avoid variable naming conflicts # Gonna make the algorithm for the reset ones as well self.reset_algorithm = config['reset_algorithm']['type']( config['algorithm']) except: pass self.saved_algorithm = copy.deepcopy( self.algorithm) # Save this newly initialized alg # If you want to warm start the algorithm BADMM with learned iLQG controllers self.diff_warm_start = True # If you want to warm start the neural network with some pretrained network self.nn_warm_start = False # The following variables determine the pretrained network path # Change these if you want to take the other policy type attention, structure = 'time', 'mlp' self.policy_path = os.path.join( self._data_files_dir, os.path.join('{}_{}'.format(attention, structure), 'policy')) try: self.old_policy_opt = copy.deepcopy(self.algorithm.policy_opt) except: pass pdb.set_trace()