tf.data.Iterator
的類型規範。
繼承自:TypeSpec
用法
tf.data.IteratorSpec(
element_spec
)
屬性
-
element_spec
tf.TypeSpec
對象的(嵌套)結構,表示迭代器元素的類型規範。 -
value_type
與此 TypeSpec 兼容的值的 Python 類型。特別是,所有與此 TypeSpec 兼容的值都必須是此類型的實例。
例如,tf.data.IteratorSpec
可用於定義一個將 tf.data.Iterator
作為輸入參數的 tf.function:
@tf.function(input_signature=[tf.data.IteratorSpec(
tf.TensorSpec(shape=(), dtype=tf.int32, name=None))])
def square(iterator):
x = iterator.get_next()
return x * x
dataset = tf.data.Dataset.from_tensors(5)
iterator = iter(dataset)
print(square(iterator))
tf.Tensor(25, shape=(), dtype=int32)
相關用法
- Python tf.data.Iterator.get_next_as_optional用法及代碼示例
- Python tf.data.Iterator.get_next用法及代碼示例
- Python tf.data.Dataset.take_while用法及代碼示例
- Python tf.data.experimental.RandomDataset.group_by_window用法及代碼示例
- Python tf.data.TFRecordDataset.filter用法及代碼示例
- Python tf.data.TextLineDataset.reduce用法及代碼示例
- Python tf.data.TextLineDataset.with_options用法及代碼示例
- Python tf.data.experimental.SqlDataset.enumerate用法及代碼示例
- Python tf.data.TextLineDataset.as_numpy_iterator用法及代碼示例
- Python tf.data.experimental.make_saveable_from_iterator用法及代碼示例
- Python tf.data.TextLineDataset.random用法及代碼示例
- Python tf.data.FixedLengthRecordDataset.repeat用法及代碼示例
- Python tf.data.TFRecordDataset.random用法及代碼示例
- Python tf.data.Dataset.cardinality用法及代碼示例
- Python tf.data.FixedLengthRecordDataset.cardinality用法及代碼示例
- Python tf.data.TextLineDataset.take_while用法及代碼示例
- Python tf.data.experimental.SqlDataset.zip用法及代碼示例
- Python tf.data.experimental.Counter用法及代碼示例
- Python tf.data.experimental.SqlDataset.shard用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.data.IteratorSpec。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。