將 Keras 對象的序列化形式轉換回實際對象。
用法
tf.keras.utils.deserialize_keras_object(
identifier, module_objects=None, custom_objects=None,
printable_module_name='object'
)
參數
-
identifier
對象的序列化形式。 -
module_objects
用於查找名稱的內置對象字典。通常,module_objects
由中級庫實現者提供。 -
custom_objects
用於查找名稱的自定義對象字典。通常,custom_objects
由最終用戶提供。 -
printable_module_name
表示對象類型的人類可讀字符串。在異常情況下打印。
返回
- 反序列化的對象。
此函數適用於mid-level 庫實施者而非最終用戶。
重要的是,此實用程序要求您提供 module_objects
的字典以用於查找對象配置;默認情況下不填充。如果您需要一個具有內置 Keras 對象知識的反序列化實用程序,請使用例如keras.layers.deserialize(config)
、 keras.metrics.deserialize(config)
等。
在 SharedObjectLoadingScope
上下文管理器下調用 deserialize_keras_object
將導致返回任何 already-seen 共享對象 as-is 而不是創建新對象。
例子:
mid-level 庫實現者可能想要實現一個實用程序來從其配置中檢索對象,如下所示:
def deserialize(config, custom_objects=None):
return deserialize_keras_object(
identifier,
module_objects=globals(),
custom_objects=custom_objects,
name="MyObjectType",
)
這就是例如keras.layers.deserialize()
已實施。
相關用法
- Python tf.keras.utils.custom_object_scope用法及代碼示例
- Python tf.keras.utils.array_to_img用法及代碼示例
- Python tf.keras.utils.get_file用法及代碼示例
- Python tf.keras.utils.experimental.DatasetCreator用法及代碼示例
- Python tf.keras.utils.set_random_seed用法及代碼示例
- Python tf.keras.utils.timeseries_dataset_from_array用法及代碼示例
- Python tf.keras.utils.plot_model用法及代碼示例
- Python tf.keras.utils.get_custom_objects用法及代碼示例
- Python tf.keras.utils.pack_x_y_sample_weight用法及代碼示例
- Python tf.keras.utils.img_to_array用法及代碼示例
- Python tf.keras.utils.image_dataset_from_directory用法及代碼示例
- Python tf.keras.utils.get_registered_object用法及代碼示例
- Python tf.keras.utils.SidecarEvaluator用法及代碼示例
- Python tf.keras.utils.to_categorical用法及代碼示例
- Python tf.keras.utils.load_img用法及代碼示例
- Python tf.keras.utils.text_dataset_from_directory用法及代碼示例
- Python tf.keras.utils.SequenceEnqueuer用法及代碼示例
- Python tf.keras.utils.unpack_x_y_sample_weight用法及代碼示例
- Python tf.keras.applications.inception_resnet_v2.preprocess_input用法及代碼示例
- Python tf.keras.metrics.Mean.merge_state用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.keras.utils.deserialize_keras_object。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。