Spec-Zone.ru › TensorFlow 2.9

tf.type_spec_from_value

Возвращает tf.TypeSpec, представляющий заданное value.

Просмотр псевдонимов

Псевдонимы совместимости для миграции

См. Руководство по миграции для получения более подробной информации.

tf.compat.v1.type_spec_from_value

tf.type_spec_from_value(
    value
) -> tf.TypeSpec

Примеры:

tf.type_spec_from_value(tf.constant([1, 2, 3]))
TensorSpec(shape=(3,), dtype=tf.int32, name=None)
tf.type_spec_from_value(np.array([4.0, 5.0], np.float64))
TensorSpec(shape=(2,), dtype=tf.float64, name=None)
tf.type_spec_from_value(tf.ragged.constant([[1, 2], [3, 4, 5]]))
RaggedTensorSpec(TensorShape([2, None]), tf.int32, 1, tf.int64)
example_input = tf.ragged.constant([[1, 2], [3]])
@tf.function(input_signature=[tf.type_spec_from_value(example_input)])
def f(x):
  return tf.reduce_sum(x, axis=1)
Аргументы
value Значение, которое может быть принято или возвращено API TensorFlow. Допустимые типы для value включают tf.Tensor, любое значение, которое может быть преобразовано в tf.Tensor с помощью tf.convert_to_tensor, и любой подкласс CompositeTensor (например, tf.RaggedTensor).
Возвращаемое значение
A TypeSpec совместимый с value.
Исключения
TypeError Если TypeSpec не может быть создан для value, потому что его тип не поддерживается.

© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/type_spec_from_value

Spec-Zone.ru

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