Change data preview to safetensor mode
Browse files- Pong-v4-expert-MCTS.py +7 -4
Pong-v4-expert-MCTS.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
import pickle
|
2 |
-
|
3 |
import datasets
|
4 |
|
|
|
5 |
_DESCRIPTION = """\
|
6 |
Data sampled from an efficient-zero policy in the pong environment. The MCTS hidden state is included in the dataset.
|
7 |
"""
|
@@ -14,7 +15,7 @@ _LICENSE = "Apache-2.0"
|
|
14 |
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
15 |
_BASE_URL = "https://huggingface.co/datasets/OpenDILabCommunity/Pong-v4-expert-MCTS/resolve/main"
|
16 |
_URLS = {
|
17 |
-
"Pong-v4-expert-MCTS": f"{_BASE_URL}/pong-v4-expert.
|
18 |
}
|
19 |
|
20 |
|
@@ -83,8 +84,10 @@ class DecisionTransformerGymDataset(datasets.GeneratorBasedBuilder):
|
|
83 |
|
84 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
85 |
def _generate_examples(self, filepath, split):
|
86 |
-
|
87 |
-
|
|
|
|
|
88 |
|
89 |
for idx in range(len(data['obs'])):
|
90 |
yield idx, {
|
|
|
1 |
import pickle
|
2 |
+
from safetensors import saveopen
|
3 |
import datasets
|
4 |
|
5 |
+
|
6 |
_DESCRIPTION = """\
|
7 |
Data sampled from an efficient-zero policy in the pong environment. The MCTS hidden state is included in the dataset.
|
8 |
"""
|
|
|
15 |
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
16 |
_BASE_URL = "https://huggingface.co/datasets/OpenDILabCommunity/Pong-v4-expert-MCTS/resolve/main"
|
17 |
_URLS = {
|
18 |
+
"Pong-v4-expert-MCTS": f"{_BASE_URL}/pong-v4-expert-new.safetensors",
|
19 |
}
|
20 |
|
21 |
|
|
|
84 |
|
85 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
86 |
def _generate_examples(self, filepath, split):
|
87 |
+
data = {}
|
88 |
+
with safe_open(filepath, framework="pt", device="cpu") as f:
|
89 |
+
for key in f.keys():
|
90 |
+
data[key] = f.get_tensor(key)
|
91 |
|
92 |
for idx in range(len(data['obs'])):
|
93 |
yield idx, {
|