Update to support split with different slipperiness (#5)
Browse files- Update to support split with different slipperiness (b43f5efad0fe6f049b46570f8442f1229115dfbf)
Co-authored-by: Nathan Schneider Gavenski <NathanGavenski@users.noreply.huggingface.co>
- frozen_lake.py +12 -8
frozen_lake.py
CHANGED
|
@@ -4,6 +4,8 @@ import tarfile
|
|
| 4 |
from os import listdir, makedirs
|
| 5 |
from os.path import isfile, join
|
| 6 |
|
|
|
|
|
|
|
| 7 |
from datasets import DatasetInfo, GeneratorBasedBuilder, Split, SplitGenerator
|
| 8 |
|
| 9 |
|
|
@@ -38,15 +40,17 @@ class ImageSet(GeneratorBasedBuilder):
|
|
| 38 |
info_path = dl_manager.download_and_extract(f"{_REPO}/resolve/main/fl_dataset.tar.gz")
|
| 39 |
image_path = dl_manager.download_and_extract(f"{_REPO}/resolve/main/images.tar.gz")
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
| 44 |
gen_kwargs={
|
| 45 |
-
"images_paths": f"{image_path}/
|
| 46 |
-
"infos": f"{info_path}/
|
| 47 |
}
|
| 48 |
-
)
|
| 49 |
-
|
| 50 |
|
| 51 |
def _generate_examples(self, images_paths, infos):
|
| 52 |
images = [join(images_paths, f) for f in listdir(images_paths) if isfile(join(images_paths, f))]
|
|
@@ -64,4 +68,4 @@ class ImageSet(GeneratorBasedBuilder):
|
|
| 64 |
"actions": record["actions"],
|
| 65 |
"rewards": record["rewards"],
|
| 66 |
"episode_starts": record["episode_starts"],
|
| 67 |
-
}
|
|
|
|
| 4 |
from os import listdir, makedirs
|
| 5 |
from os.path import isfile, join
|
| 6 |
|
| 7 |
+
import numpy as np
|
| 8 |
+
|
| 9 |
from datasets import DatasetInfo, GeneratorBasedBuilder, Split, SplitGenerator
|
| 10 |
|
| 11 |
|
|
|
|
| 40 |
info_path = dl_manager.download_and_extract(f"{_REPO}/resolve/main/fl_dataset.tar.gz")
|
| 41 |
image_path = dl_manager.download_and_extract(f"{_REPO}/resolve/main/images.tar.gz")
|
| 42 |
|
| 43 |
+
split = []
|
| 44 |
+
for value in np.arange(0.0, 0.55, 0.05):
|
| 45 |
+
value = round(value, 2)
|
| 46 |
+
split.append(SplitGenerator(
|
| 47 |
+
name="%.2f" % value,
|
| 48 |
gen_kwargs={
|
| 49 |
+
"images_paths": f"{image_path}/images_{value}",
|
| 50 |
+
"infos": f"{info_path}/teacher_{value}.jsonl"
|
| 51 |
}
|
| 52 |
+
))
|
| 53 |
+
return split
|
| 54 |
|
| 55 |
def _generate_examples(self, images_paths, infos):
|
| 56 |
images = [join(images_paths, f) for f in listdir(images_paths) if isfile(join(images_paths, f))]
|
|
|
|
| 68 |
"actions": record["actions"],
|
| 69 |
"rewards": record["rewards"],
|
| 70 |
"episode_starts": record["episode_starts"],
|
| 71 |
+
}
|