File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
tensorflow_datasets/robotics Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 18
18
from tensorflow_datasets .robotics import dataset_importer_builder
19
19
20
20
ASIMOV_CITATION = """
21
- @article{Sermanet2025RobotConstitutions ,
21
+ @article{sermanet2025asimov ,
22
22
author = {Pierre Sermanet and Anirudha Majumdar and Alex Irpan and Dmitry Kalashnikov and Vikas Sindhwani},
23
23
title = {Generating Robot Constitutions & Benchmarks for Semantic Safety},
24
- journal = {arXiv preprint arXiv:FIXME },
25
- url = {https://arxiv.org/abs/FIXME },
24
+ journal = {arXiv preprint arXiv:2503.08663 },
25
+ url = {https://arxiv.org/abs/2503.08663 },
26
26
year = {2025},
27
27
}
28
28
"""
Original file line number Diff line number Diff line change 28
28
from tensorflow_datasets .core .utils import read_config as read_config_lib
29
29
from tensorflow_datasets .core .utils .lazy_imports_utils import tensorflow as tf
30
30
import tensorflow_datasets .public_api as tfds
31
+ import tree
31
32
32
33
33
34
@@ -218,7 +219,7 @@ def _generate_examples(
218
219
read_config = read_config_lib .ReadConfig (add_tfds_id = True )
219
220
220
221
def converter_fn (example ):
221
- example_out = dataset_utils . as_numpy ( example )
222
+ example_out = tree . map_structure ( to_np , example )
222
223
example_id = example_out ['tfds_id' ].decode ('utf-8' )
223
224
del example_out ['tfds_id' ]
224
225
@@ -235,3 +236,10 @@ def get_ds_builder(self):
235
236
ds_location = self .get_dataset_location ()
236
237
ds_builder = tfds .builder_from_directory (ds_location )
237
238
return ds_builder
239
+
240
+
241
+ def to_np (tensor ):
242
+ """Convert tensor to numpy."""
243
+ if isinstance (tensor , tf .Tensor ) or isinstance (tensor , tf .RaggedTensor ):
244
+ return tensor .numpy ()
245
+ return tensor
You can’t perform that action at this time.
0 commit comments