I want to apply the same effect as (.choose_from_datasets) method
but to the tf.string elements inside my list_ds that have 30 tf.string items. How can I do this?
list_ds = tf.data.Dataset.list_files(str(PATH/'Pasta_test/*'), shuffle=False)
print(list_ds)
for i in list_ds.take(2):
print(i)
print('--------------------------------------------------------------------------------------------------------------------')
#-------(.choose_from_datasets) method ----- https://www.tensorflow.org/api_docs/python/tf/data/Dataset#choose_from_datasets
datasets = [tf.data.Dataset.from_tensors("Tokyo"),
tf.data.Dataset.from_tensors("Berlin"),
tf.data.Dataset.from_tensors("Spiderman"),
tf.data.Dataset.from_tensors("Batman"),]
# Define a dataset containing `[0, 1, 2, 0, 1, 2, 0, 1, 2]`.
choice_dataset = tf.data.Dataset.range(2,4)
result = tf.data.Dataset.choose_from_datasets(datasets, choice_dataset)
#-----------------------------------------------------------------------------------------------------------------------------
print('%s \n' %datasets)
for i in result:
print(i)