Spec-Zone.ru › TensorFlow 1.15

tf.compat.dimension_at_index

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

Утилита совместимости, необходимая для поддержки как поведения V1, так и V2 в TF.

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

Основные псевдонимы

`tf.dimension_at_index`

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

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

tf.compat.v1.compat.dimension_at_index, tf.compat.v1.dimension_at_index, `tf.compat.v2.compat.dimension_at_index`

tf.compat.dimension_at_index(
    shape, index
)

До выхода TF 2.0 нам необходимо, чтобы устаревшее поведение TensorShape сосуществовало с новым поведением. Эта утилита служит мостом между ними.

Если вы хотите получить экземпляр Dimension, соответствующий определенному индексу в экземпляре TensorShape, воспользуйтесь этой утилитой, как показано ниже:

# If you had this in your V1 code:
dim = tensor_shape[i]

# Use `dimension_at_index` as direct replacement compatible with both V1 & V2:
dim = dimension_at_index(tensor_shape, i)

# Another possibility would be this, but WARNING: it only works if the
# tensor_shape instance has a defined rank.
dim = tensor_shape.dims[i]  # `dims` may be None if the rank is undefined!

# In native V2 code, we recommend instead being more explicit:
if tensor_shape.rank is None:
  dim = Dimension(None)
else:
  dim = tensor_shape.dims[i]

# Being more explicit will save you from the following trap (present in V1):
# you might do in-place modifications to `dim` and expect them to be reflected
# in `tensor_shape[i]`, but they would not be (as the Dimension object was
# instantiated on the fly.
Аргументы
shape Экземпляр TensorShape.
index Целое числовой индекс.
Возвращает
Объект dimension.

© 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/r1.15/api_docs/python/tf/compat/dimension_at_index

Spec-Zone.ru

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