| 192 | return action |
| 193 | |
| 194 | def unscale_action(self, action: np.ndarray, eps=0.0) -> np.ndarray: |
| 195 | # input action \in [d_low, d_high] |
| 196 | # output action \in [a_low+eps, a_high-eps] |
| 197 | d_low, d_high = self.action_dist.low, self.action_dist.high # scalar |
| 198 | |
| 199 | if d_low is not None and d_high is not None: |
| 200 | # batch_size = action.shape[0] |
| 201 | a_low, a_high = self.action_space.low, self.action_space.high |
| 202 | # same shape as action [batch_size, action_dim] |
| 203 | # a_high = np.tile(self.action_space.high, [batch_size, 1]) |
| 204 | action = (action-d_low)/(d_high-d_low) * (a_high-a_low) + a_low |
| 205 | # action = np.clip(action, a_low+eps, a_high-eps) |
| 206 | return action |
| 207 | |
| 208 | def get_init_kwargs(self) -> Dict[str, Any]: |
| 209 | init_kwargs = dict( |