hucc/envs/ctrlgs.py [281:308]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        N = 128
        cand = self.sample_goals_random(N=N)
        if self.backproject_goal:
            s = self.goal_featurizer()[self.task_idx]
            gb = (np.matmul(cand, self.psi_1[self._features]) + self.offset_1)[
                :, self.task_idx
            ]
            g = gb - s
            g *= self._feature_mask
        else:
            gs = self.proj(self.goal_featurizer(), self._features)
            g = np.zeros((N, self.observation_space['desired_goal'].shape[0]))
            g[:, 0 : len(self._features)] = cand - gs

        obs = super().get_observation()[self.obs_mask]
        inp = {
            'observation': th.tensor(obs, dtype=th.float32)
            .unsqueeze(0)
            .expand(N, obs.shape[0]),
            'desired_goal': th.tensor(g, dtype=th.float32),
            'task': th.tensor(self._feature_mask, dtype=th.float32)
            .unsqueeze(0)
            .expand(N, self._feature_mask.shape[0]),
        }
        with th.no_grad():
            action = self.model.pi(inp).mean
        inp['action'] = action
        with th.no_grad():
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



hucc/envs/ctrlgs.py [319:346]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        N = 128
        cand = self.sample_goals_random(N=N)
        if self.backproject_goal:
            s = self.goal_featurizer()[self.task_idx]
            gb = (np.matmul(cand, self.psi_1[self._features]) + self.offset_1)[
                :, self.task_idx
            ]
            g = gb - s
            g *= self._feature_mask
        else:
            gs = self.proj(self.goal_featurizer(), self._features)
            g = np.zeros((N, self.observation_space['desired_goal'].shape[0]))
            g[:, 0 : len(self._features)] = cand - gs

        obs = super().get_observation()[self.obs_mask]
        inp = {
            'observation': th.tensor(obs, dtype=th.float32)
            .unsqueeze(0)
            .expand(N, obs.shape[0]),
            'desired_goal': th.tensor(g, dtype=th.float32),
            'task': th.tensor(self._feature_mask, dtype=th.float32)
            .unsqueeze(0)
            .expand(N, self._feature_mask.shape[0]),
        }
        with th.no_grad():
            action = self.model.pi(inp).mean
        inp['action'] = action
        with th.no_grad():
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



