I want to ask if there exists a method that can help me transform a tf.data.dataset to a datasets.dataset.
Hi! We don’t have a dedicated method for converting tf.data.Dataset
to datasets.Dataset
, only the other way around.
So you have two options:
- If the dataset is small and fits in RAM, you can convert the TF dataset to a Python dictionary and then call
datasets.Dataset.from_dict
on it. Another approach that might be easier is to install Tensorflow Datasets and convert the TF dataset to a Pandas DataFrame, on which you can calldatasets.Dataset.from_pandas
:datasets.Dataset.from_pandas(tfds.as_dataframe(tf_dataset))
- If the dataset doesn’t fit in RAM, you can create a simple loading script in which you iterate over the dataset and yield its examples in
_generate_examples
. You can find more info here: Create a dataset loading script.