[英]How to load TensorFlow Keras model from a saved checkpoint in Colaboratory?
I've built and trained an RNN model in Colaboratory, and saved it using the checkpoint callback:我在 Colaboratory 中构建并训练了一个 RNN model,并使用检查点回调将其保存:
tf.keras.callbacks.ModelCheckpoint( filepath=chkpt_p, save_weights_only=False)
And the saved data looks like this:保存的数据如下所示:
If I understand correctly, this directory includes both the model and the weights.如果我没理解错的话,这个目录包括 model 和权重。 Which function should I use to restore it (in another runtime)?我应该使用哪个 function 来恢复它(在另一个运行时)?
This worked for me:这对我有用:
model = tf.keras.models.load_model(save_dir,compile=False)
I had one issue with using tf.saved_model.load
, which doesn't produce a keras object, and one TF not finding the loss function with compile=True
.我在使用tf.saved_model.load
时遇到了一个问题,它不会产生 keras object,并且一个 TF 找不到损失 function 与compile=True
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.