Misha Lvovsky commited on
Commit ·
29d3434
1
Parent(s): ec4d7aa
Just got rid of try-except block in decoding
Browse filesGetting rid of the try-except block makes it easier to see when the
error occurrs and change behavior if it does in my code
- processing_action_tokenizer.py +10 -15
processing_action_tokenizer.py
CHANGED
|
@@ -77,21 +77,16 @@ class UniversalActionProcessor(ProcessorMixin):
|
|
| 77 |
|
| 78 |
decoded_actions = []
|
| 79 |
for token in tokens:
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
), f"Decoded DCT coefficients have shape {decoded_dct_coeff.shape}, expected ({self.time_horizon}, {self.action_dim})"
|
| 91 |
-
except Exception as e:
|
| 92 |
-
print(f"Error decoding tokens: {e}")
|
| 93 |
-
print(f"Tokens: {token}")
|
| 94 |
-
decoded_dct_coeff = np.zeros((self.time_horizon, self.action_dim))
|
| 95 |
decoded_actions.append(idct(decoded_dct_coeff / self.scale, axis=0, norm="ortho"))
|
| 96 |
return np.stack(decoded_actions)
|
| 97 |
|
|
|
|
| 77 |
|
| 78 |
decoded_actions = []
|
| 79 |
for token in tokens:
|
| 80 |
+
decoded_tokens = self.bpe_tokenizer.decode(token)
|
| 81 |
+
decoded_dct_coeff = np.array(list(map(ord, decoded_tokens))) + self.min_token
|
| 82 |
+
decoded_dct_coeff = decoded_dct_coeff.reshape(-1, self.action_dim)
|
| 83 |
+
assert (
|
| 84 |
+
decoded_dct_coeff.shape
|
| 85 |
+
== (
|
| 86 |
+
self.time_horizon,
|
| 87 |
+
self.action_dim,
|
| 88 |
+
)
|
| 89 |
+
), f"Decoded DCT coefficients have shape {decoded_dct_coeff.shape}, expected ({self.time_horizon}, {self.action_dim})"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
decoded_actions.append(idct(decoded_dct_coeff / self.scale, axis=0, norm="ortho"))
|
| 91 |
return np.stack(decoded_actions)
|
| 92 |
|