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