用法
enumerate(
start=0, name=None
)
參數
返回
-
Dataset
一個Dataset
。
枚舉此數據集的元素。
它類似於 python 的 enumerate
。
dataset = tf.data.Dataset.from_tensor_slices([1, 2, 3])
dataset = dataset.enumerate(start=5)
for element in dataset.as_numpy_iterator():
print(element)
(5, 1)
(6, 2)
(7, 3)
# The (nested) structure of the input dataset determines the
# structure of elements in the resulting dataset.
dataset = tf.data.Dataset.from_tensor_slices([(7, 8), (9, 10)])
dataset = dataset.enumerate()
for element in dataset.as_numpy_iterator():
print(element)
(0, array([7, 8], dtype=int32))
(1, array([ 9, 10], dtype=int32))
相關用法
- Python tf.compat.v1.data.experimental.CsvDataset.reduce用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.apply用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.take用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.cache用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.from_generator用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.make_one_shot_iterator用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.bucket_by_sequence_length用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.map用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.filter用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.window用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.take_while用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.repeat用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.padded_batch用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.scan用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.flat_map用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.rejection_resample用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.choose_from_datasets用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.skip用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.from_tensor_slices用法及代碼示例
- Python tf.compat.v1.data.experimental.CsvDataset.get_single_element用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.compat.v1.data.experimental.CsvDataset.enumerate。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。