Spec-Zone.ru › TensorFlow 2.4

tf.data.IteratorSpec

Спецификация типа для tf.data.Iterator.

Наследуется от: TypeSpec

tf.data.IteratorSpec(
    element_spec
)

Например, tf.data.IteratorSpec можно использовать для определения tf.function, принимающего tf.data.Iterator в качестве входного аргумента:

@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)
Атрибуты
element_spec Вложенная структура объектов TypeSpec, представляющая спецификацию типа элементов итератора.
value_type Тип Python для значений, совместимых с этим TypeSpec.

В частности, все значения, совместимые с этим TypeSpec, должны быть экземплярами этого типа.

Методы

from_value

Просмотреть исходный код

@staticmethod
from_value(
    value
)

is_compatible_with

Просмотреть исходный код

is_compatible_with(
    spec_or_value
)

Возвращает true, если spec_or_value совместим с этим TypeSpec.

most_specific_compatible_type

Просмотреть исходный код

most_specific_compatible_type(
    other
)

Возвращает самую специфическую TypeSpec, совместимую с self и other.

Аргументы
other A TypeSpec.
Исключения
ValueError Если нет TypeSpec, совместимой с обоими self и other.

__eq__

Просмотреть исходный код

__eq__(
    other
)

Возвращает self==value.

__ne__

Просмотреть исходный код

__ne__(
    other
)

Возвращает self!=value.

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.4/api_docs/python/tf/data/IteratorSpec

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API