Tensorflow: how to save/restore a model?

前端 未结 26 2546
迷失自我
迷失自我 2020-11-21 11:37

After you train a model in Tensorflow:

  1. How do you save the trained model?
  2. How do you later restore this saved model?
26条回答
  •  有刺的猬
    2020-11-21 12:07

    For tensorflow 2.0, it is as simple as

    # Save the model
    model.save('path_to_my_model.h5')
    

    To restore:

    new_model = tensorflow.keras.models.load_model('path_to_my_model.h5')
    

提交回复
热议问题