How can we plot accuracy and loss graphs from a Keras model saved earlier?

后端 未结 2 662
不知归路
不知归路 2020-12-17 07:08

Is there a way to plot accuracy and loss graphs from the CNN model saved earlier? Or can we only plot graphs during training and evaluating the model?

model          


        
2条回答
  •  猫巷女王i
    2020-12-17 07:30

    It depends on the way you saved the model.

    In general, there are two cases, the first one is saving and loading the whole model (including architecture and weights):

    from keras.models import load_model
    
    model.save('my_model.h5')  # creates a HDF5 file 'my_model.h5'
    ...
    model = load_model('my_model.h5')
    

    The second is saving only the weights:

    def create_model():
       model = Sequential() 
       # ... creating the model exactly as it was defined in the training time
    
    # You must create the model since loading only the weights
    model = create_model()
    model.load_weights('my_model_weights.h5')
    

    For more details read Keras documentation

提交回复
热议问题