Loading a Saved Keras Model in TensorFlow
The first line of code loads a saved model from a file named 'model.h5'. It specifies the encoding as 'utf-8' and passes a dictionary of custom objects as an argument to the 'custom_objects' parameter. The '<custom_objects>' should be replaced with the actual custom objects required for the model.
model = tf.keras.models.load_model('model.h5', encoding='utf-8', compile=False, custom_objects={'<custom_objects>'})
The second line of code also loads a saved model from a file named 'model.h5'. However, it does not specify any encoding or custom objects. The 'compile' parameter is set to False, which means the loaded model will not be compiled with the optimizer and loss function specified during training.
model = tf.keras.models.load_model('model.h5', compile=False)
原文地址: http://www.cveoy.top/t/topic/pghH 著作权归作者所有。请勿转载和采集!