tf.keras.utils.custom_object_scope
| Просмотреть исходный код на GitHub |
Предоставляет доступ к настраиваемым классам/функциям для внутренней десериализации Keras.
tf.keras.utils.custom_object_scope(
*args
)
В рамках области with custom_object_scope(objects_dict), методы Keras, такие как tf.keras.models.load_model или tf.keras.models.model_from_config, смогут десериализовать любой настраиваемый объект, на который ссылается сохраненная конфигурация (например, настраиваемый слой или метрику).
Пример:
Рассмотрим настраиваемый регуляризатор my_regularizer:
layer = Dense(3, kernel_regularizer=my_regularizer)
config = layer.get_config() # Config contains a reference to `my_regularizer`
...
# Later:
with custom_object_scope({'my_regularizer': my_regularizer}):
layer = Dense.from_config(config)
| Аргументы | |
|---|---|
*args | Словарь или словари пар {name: object}. |
Методы
__enter__
__enter__()
__exit__
__exit__(
*args, **kwargs
)
© 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/versions/r2.9/api_docs/python/tf/keras/utils/custom_object_scope