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