def __init__(self, observation_space, hidden_size): super().__init__() if (IntegratedPointGoalGPSAndCompassSensor.cls_uuid in observation_space.spaces): self._n_input_goal = observation_space.spaces[ IntegratedPointGoalGPSAndCompassSensor.cls_uuid].shape[0] elif PointGoalSensor.cls_uuid in observation_space.spaces: self._n_input_goal = observation_space.spaces[ PointGoalSensor.cls_uuid].shape[0] elif ImageGoalSensor.cls_uuid in observation_space.spaces: goal_observation_space = spaces.Dict( {"rgb": observation_space.spaces[ImageGoalSensor.cls_uuid]}) self.goal_visual_encoder = SimpleCNN(goal_observation_space, hidden_size) self._n_input_goal = hidden_size self._hidden_size = hidden_size self.visual_encoder = SimpleCNN(observation_space, hidden_size) self.state_encoder = RNNStateEncoder( (0 if self.is_blind else self._hidden_size) + self._n_input_goal, self._hidden_size, ) self.train()
def __init__( self, observation_space: spaces.Dict, hidden_size: int, goal_hidden_size, fuse_states, force_blind, normalize_vis, normalize_state, ): super().__init__() if TargetPointGoalGPSAndCompassSensor.cls_uuid in observation_space.spaces: self._n_input_goal = observation_space.spaces[ TargetPointGoalGPSAndCompassSensor.cls_uuid].shape[0] elif (IntegratedPointGoalGPSAndCompassSensor.cls_uuid in observation_space.spaces): self._n_input_goal = observation_space.spaces[ IntegratedPointGoalGPSAndCompassSensor.cls_uuid].shape[0] elif PointGoalSensor.cls_uuid in observation_space.spaces: self._n_input_goal = observation_space.spaces[ PointGoalSensor.cls_uuid].shape[0] elif ImageGoalSensor.cls_uuid in observation_space.spaces: goal_observation_space = spaces.Dict( {"rgb": observation_space.spaces[ImageGoalSensor.cls_uuid]}) self.goal_visual_encoder = SimpleCNN(goal_observation_space, hidden_size, False, False) self._n_input_goal = hidden_size else: self.fuse_states = fuse_states self._n_input_goal = sum([ observation_space.spaces[n].shape[0] for n in self.fuse_states ]) self._hidden_size = hidden_size self._goal_hidden_size = goal_hidden_size self.visual_encoder = SimpleCNN(observation_space, hidden_size, force_blind, normalize_vis) state_dim = self._n_input_goal if self._goal_hidden_size != 0: self.goal_encoder = nn.Sequential( nn.Linear(self._n_input_goal, self._goal_hidden_size), nn.ReLU(), nn.Linear(self._goal_hidden_size, self._goal_hidden_size), nn.ReLU()) state_dim = self._goal_hidden_size if normalize_state: self.state_norm = RunningMeanAndVar(self._n_input_goal, []) else: self.state_norm = nn.Sequential() self.state_encoder = build_rnn_state_encoder( (0 if self.is_blind else self._hidden_size) + state_dim, self._hidden_size, ) self.train()
def __init__(self, observation_space, hidden_size, goal_sensor_uuid): super().__init__() self.goal_sensor_uuid = goal_sensor_uuid self._n_input_goal = observation_space.spaces[self.goal_sensor_uuid].shape[0] self._hidden_size = hidden_size self.visual_encoder = SimpleCNN(observation_space, hidden_size) self.state_encoder = RNNStateEncoder( (0 if self.is_blind else self._hidden_size) + self._n_input_goal, self._hidden_size, ) self.train()