Discretize continuous actions to tokens. action: np.ndarray, (n, 7), continuous actions in Cartesian or Spherical coordinates. return: np.ndarray, (n, 7), tokens.
(self, action: np.ndarray)
| 35 | self.token_end_idx = self.tokenizer.convert_tokens_to_ids(self.token_array[-1]) |
| 36 | |
| 37 | def __call__(self, action: np.ndarray) -> List[str]: |
| 38 | """Discretize continuous actions to tokens. |
| 39 | action: np.ndarray, (n, 7), continuous actions in Cartesian or Spherical coordinates. |
| 40 | return: np.ndarray, (n, 7), tokens. |
| 41 | """ |
| 42 | action = np.clip(action, a_min=float(self.min_action), a_max=float(self.max_action)) |
| 43 | ids = np.digitize(action, self.bin_centers, right=True) # [0, 255] |
| 44 | return self.token_array[ids] |
| 45 | |
| 46 | def decode_token_ids_to_actions(self, action_token_id: np.ndarray) -> np.ndarray: |
| 47 | """decode token ids to continuous actions. |
nothing calls this directly
no outgoing calls
no test coverage detected