ravens/agents/gt_state_2_step.py
def init_model(self, dataset):
        """Initialize models, including normalization parameters."""
        self.set_max_obs_vector_length(dataset)

        if self.goal_conditioned:
            _, _, info, goal = dataset.random_sample(goal_images=True)
            obs_vector = self.info_to_gt_obs(info, goal=goal)
        else:
            _, _, info = dataset.random_sample()
            obs_vector = self.info_to_gt_obs(info)

        # Setup pick model, which only has act_dim=3 unlike act_dim=6 for gt_state.
        obs_dim = obs_vector.shape[0]
        act_dim = 3
        self.pick_model = MlpModel(self.BATCH_SIZE, obs_dim, act_dim, 'relu', self.USE_MDN, dropout=0.1)

        # Sample points from the data to get reasonable mean / std values.
        sampled_gt_obs = []
        num_samples = 1000
        for _ in range(num_samples):
            t_worldaug_world, _ = self.get_augmentation_transform()
            if self.goal_conditioned:
                _, _, info, goal = dataset.random_sample(goal_images=True)
                sampled_gt_obs.append(self.info_to_gt_obs(info, t_worldaug_world, goal=goal))
            else:
                _, _, info = dataset.random_sample()
                sampled_gt_obs.append(self.info_to_gt_obs(info, t_worldaug_world))
        sampled_gt_obs = np.array(sampled_gt_obs)
        obs_train_parameters = dict()
        obs_train_parameters['mean'] = sampled_gt_obs.mean(axis=(0)).astype(np.float32)
        obs_train_parameters['std']  = sampled_gt_obs.std(axis=(0)).astype(np.float32)
        self.pick_model.set_normalization_parameters(obs_train_parameters)
        self.pick_obs_train_mean = obs_train_parameters['mean']
        self.pick_obs_train_std  = obs_train_parameters['std']

        # Setup pick-conditioned place model, which adds `act_dim` to `obs_dim`.
        obs_dim = obs_vector.shape[0] + act_dim
        act_dim = 3
        self.place_model = MlpModel(self.BATCH_SIZE, obs_dim, act_dim, 'relu', self.USE_MDN, dropout=0.1)

        # Sample points from the data to get reasonable mean / std values.
        sampled_gt_obs = []
        num_samples = 1000
        for _ in range(num_samples):
            t_worldaug_world, _ = self.get_augmentation_transform()
            if self.goal_conditioned:
                _, act, info, goal = dataset.random_sample(goal_images=True)
                obs = self.info_to_gt_obs(info, t_worldaug_world, goal=goal)
            else:
                _, act, info = dataset.random_sample()
                obs = self.info_to_gt_obs(info, t_worldaug_world)
            obs = np.hstack((obs, self.act_to_gt_act(act, t_worldaug_world)[:3]))  # Daniel: key difference?
            sampled_gt_obs.append(obs)
        sampled_gt_obs = np.array(sampled_gt_obs)
        obs_train_parameters = dict()
        obs_train_parameters['mean'] = sampled_gt_obs.mean(axis=(0)).astype(np.float32)
        obs_train_parameters['std']  = sampled_gt_obs.std(axis=(0)).astype(np.float32)
        self.place_model.set_normalization_parameters(obs_train_parameters)
        self.place_obs_train_mean = obs_train_parameters['mean']
        self.place_obs_train_std  = obs_train_parameters['std']

        print('Done initializing self.model for ground truth agent.')
Initialize models, including normalization parameters.
Initialize models, including normalization parameters.
Initialize models including normalization parameters .
def init_model(self, dataset):
        self.set_max_obs_vector_length(dataset)
        if self.goal_conditioned:
            _, _, info, goal = dataset.random_sample(goal_images=True)
            obs_vector = self.info_to_gt_obs(info, goal=goal)
        else:
            _, _, info = dataset.random_sample()
            obs_vector = self.info_to_gt_obs(info)
        obs_dim = obs_vector.shape[0]
        act_dim = 3
        self.pick_model = MlpModel(self.BATCH_SIZE, obs_dim, act_dim, 'relu', self.USE_MDN, dropout=0.1)
        sampled_gt_obs = []
        num_samples = 1000
        for _ in range(num_samples):
            t_worldaug_world, _ = self.get_augmentation_transform()
            if self.goal_conditioned:
                _, _, info, goal = dataset.random_sample(goal_images=True)
                sampled_gt_obs.append(self.info_to_gt_obs(info, t_worldaug_world, goal=goal))
            else:
                _, _, info = dataset.random_sample()
                sampled_gt_obs.append(self.info_to_gt_obs(info, t_worldaug_world))
        sampled_gt_obs = np.array(sampled_gt_obs)
        obs_train_parameters = dict()
        obs_train_parameters['mean'] = sampled_gt_obs.mean(axis=(0)).astype(np.float32)
        obs_train_parameters['std']  = sampled_gt_obs.std(axis=(0)).astype(np.float32)
        self.pick_model.set_normalization_parameters(obs_train_parameters)
        self.pick_obs_train_mean = obs_train_parameters['mean']
        self.pick_obs_train_std  = obs_train_parameters['std']
        obs_dim = obs_vector.shape[0] + act_dim
        act_dim = 3
        self.place_model = MlpModel(self.BATCH_SIZE, obs_dim, act_dim, 'relu', self.USE_MDN, dropout=0.1)
        sampled_gt_obs = []
        num_samples = 1000
        for _ in range(num_samples):
            t_worldaug_world, _ = self.get_augmentation_transform()
            if self.goal_conditioned:
                _, act, info, goal = dataset.random_sample(goal_images=True)
                obs = self.info_to_gt_obs(info, t_worldaug_world, goal=goal)
            else:
                _, act, info = dataset.random_sample()
                obs = self.info_to_gt_obs(info, t_worldaug_world)
            obs = np.hstack((obs, self.act_to_gt_act(act, t_worldaug_world)[:3]))  
            sampled_gt_obs.append(obs)
        sampled_gt_obs = np.array(sampled_gt_obs)
        obs_train_parameters = dict()
        obs_train_parameters['mean'] = sampled_gt_obs.mean(axis=(0)).astype(np.float32)
        obs_train_parameters['std']  = sampled_gt_obs.std(axis=(0)).astype(np.float32)
        self.place_model.set_normalization_parameters(obs_train_parameters)
        self.place_obs_train_mean = obs_train_parameters['mean']
        self.place_obs_train_std  = obs_train_parameters['std']
        print('Done initializing self.model for ground truth agent.')
def init_model ( self , dataset ) : self . set_max_obs_vector_length ( dataset ) if self . goal_conditioned : _ , _ , info , goal = dataset . random_sample ( goal_images = True ) obs_vector = self . info_to_gt_obs ( info , goal = goal ) else : _ , _ , info = dataset . random_sample ( ) obs_vector = self . info_to_gt_obs ( info ) obs_dim = obs_vector . shape [ 0 ] act_dim = 3 self . pick_model = MlpModel ( self . BATCH_SIZE , obs_dim , act_dim , 'relu' , self . USE_MDN , dropout = 0.1 ) sampled_gt_obs = [ ] num_samples = 1000 for _ in range ( num_samples ) : t_worldaug_world , _ = self . get_augmentation_transform ( ) if self . goal_conditioned : _ , _ , info , goal = dataset . random_sample ( goal_images = True ) sampled_gt_obs . append ( self . info_to_gt_obs ( info , t_worldaug_world , goal = goal ) ) else : _ , _ , info = dataset . random_sample ( ) sampled_gt_obs . append ( self . info_to_gt_obs ( info , t_worldaug_world ) ) sampled_gt_obs = np . array ( sampled_gt_obs ) obs_train_parameters = dict ( ) obs_train_parameters [ 'mean' ] = sampled_gt_obs . mean ( axis = ( 0 ) ) . astype ( np . float32 ) obs_train_parameters [ 'std' ] = sampled_gt_obs . std ( axis = ( 0 ) ) . astype ( np . float32 ) self . pick_model . set_normalization_parameters ( obs_train_parameters ) self . pick_obs_train_mean = obs_train_parameters [ 'mean' ] self . pick_obs_train_std = obs_train_parameters [ 'std' ] obs_dim = obs_vector . shape [ 0 ] + act_dim act_dim = 3 self . place_model = MlpModel ( self . BATCH_SIZE , obs_dim , act_dim , 'relu' , self . USE_MDN , dropout = 0.1 ) sampled_gt_obs = [ ] num_samples = 1000 for _ in range ( num_samples ) : t_worldaug_world , _ = self . get_augmentation_transform ( ) if self . goal_conditioned : _ , act , info , goal = dataset . random_sample ( goal_images = True ) obs = self . info_to_gt_obs ( info , t_worldaug_world , goal = goal ) else : _ , act , info = dataset . random_sample ( ) obs = self . info_to_gt_obs ( info , t_worldaug_world ) obs = np . hstack ( ( obs , self . act_to_gt_act ( act , t_worldaug_world ) [ : 3 ] ) ) sampled_gt_obs . append ( obs ) sampled_gt_obs = np . array ( sampled_gt_obs ) obs_train_parameters = dict ( ) obs_train_parameters [ 'mean' ] = sampled_gt_obs . mean ( axis = ( 0 ) ) . astype ( np . float32 ) obs_train_parameters [ 'std' ] = sampled_gt_obs . std ( axis = ( 0 ) ) . astype ( np . float32 ) self . place_model . set_normalization_parameters ( obs_train_parameters ) self . place_obs_train_mean = obs_train_parameters [ 'mean' ] self . place_obs_train_std = obs_train_parameters [ 'std' ] print ( 'Done initializing self.model for ground truth agent.' )
Initialize models, including normalization parameters.
Initialize models including normalization parameters .
"""Initialize models, including normalization parameters.""" # Setup pick model, which only has act_dim=3 unlike act_dim=6 for gt_state. # Sample points from the data to get reasonable mean / std values. # Setup pick-conditioned place model, which adds `act_dim` to `obs_dim`. # Sample points from the data to get reasonable mean / std values. # Daniel: key difference?
self
dataset