ValueError: Unable to restore custom object of class “MeanMetricWrapper“ (type _tf_keras_metric)

ValueError: Unable to restore custom object of class "MeanMetricWrapper" (type _tf_keras_metric). Please make sure that this class is included in the `custom_objects` arg when calling `load_model()`. Also, check that the class implements `get_config` and `from_config`.

Complete metadata: {'class_name': 'MeanMetricWrapper', 'name': 'r2', 'dtype': 'float32', 'config': {'name': 'r2', 'dtype': 'float32'}, 'shared_object_id': 13}

 读取模型时报错:

new_model = tf.keras.models.load_model('./saved_model/blood_model')

解决办法:

new_model = tf.keras.models.load_model('./saved_model/blood_model',compile=False,
                custom_objects={"TrajGRUCell":'TrajGRUCell',"TrajGRU":'TrajGRU'})

ok!

你可能感兴趣的:(【Keras】,keras,tensorflow,人工智能)