Spec-Zone.ru › TensorFlow

tf.keras.tree.assert_same_structure

Утверждает, что две структуры вложены одинаковым образом.

tf.keras.tree.assert_same_structure(
    a, b, check_types=True
)

Обратите внимание, что именованные кортежи с идентичными именем и полями не будут считаться одинаковыми структурами, даже check_types=False.

Примеры:

keras.tree.assert_same_structure([(0, 1)], [(2, 3)])
Foo = collections.namedtuple('Foo', ['a', 'b'])
AlsoFoo = collections.namedtuple('Foo', ['a', 'b'])
keras.tree.assert_same_structure(Foo(0, 1), Foo(2, 3))
keras.tree.assert_same_structure(Foo(0, 1), AlsoFoo(2, 3))
Traceback (most recent call last):

ValueError: `a` and `b` don't have the same structure.
Аргументы
a произвольно вложенная структура.
b произвольно вложенная структура.
check_types если True (по умолчанию) проверяются также типы листьев.

© 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/api_docs/python/tf/keras/tree/assert_same_structure

Spec-Zone.ru

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