Spec-Zone.ru › TensorFlow

tf.keras.tree.map_structure_up_to

Применяет func к переданным структурам вплоть до shallow_structure.

tf.keras.tree.map_structure_up_to(
    shallow_structure, func, *structures
)

Это вариант map_structure, который применяет функцию к переданным структурам только вплоть до shallow_structure. Все более глубоко вложенные компоненты остаются без изменений.

Примеры:

shallow_structure = [None, None]
structure = [[1, 1], [2, 2]]
keras.tree.map_structure_up_to(shallow_structure, len, structure)
[2, 2]
shallow_structure = [None, [None, None]]
keras.tree.map_structure_up_to(shallow_structure, str, structure)
['[1, 1]', ['2', '2']]
Аргументы
shallow_structure Структура с общей схемой для всех structures.
func Вызываемый объект, принимающий столько аргументов, сколько имеется структур.
*structures Произвольно вложенные структуры с одинаковой схемой.
Возвращает
Новая структура с той же схемой, что и у shallow_structure.

© 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/map_structure_up_to

Spec-Zone.ru

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