用法
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.FixedLengthRecordDataset.skip用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.take用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.apply用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.random用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.bucket_by_sequence_length用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.cache用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.unique用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.make_initializable_iterator用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.make_one_shot_iterator用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.map用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.snapshot用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.shard用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.with_options用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.flat_map用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.from_generator用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.unbatch用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.repeat用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.group_by_window用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.rejection_resample用法及代碼示例
- Python tf.compat.v1.data.FixedLengthRecordDataset.from_tensor_slices用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.compat.v1.data.FixedLengthRecordDataset.enumerate。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。