keras: how to save the training history attribute of the history object

前端 未结 8 2032
小鲜肉
小鲜肉 2020-12-12 23:43

In Keras, we can return the output of model.fit to a history as follows:

 history = model.fit(X_train, y_train, 
                     batch_size         


        
8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-13 00:09

    The above answers are useful when saving history at the end of the training process. If you want to save the history during the training, the CSVLogger callback will be helpful.

    Below code saves the model weight and history training in form of a datasheet file log.csv.

    model_cb = tf.keras.callbacks.ModelCheckpoint(filepath=checkpoint_path)
    history_cb = tf.keras.callbacks.CSVLogger('./log.csv', separator=",", append=False)
    
    history = model.fit(callbacks=[model_cb, history_cb])
    

提交回复
热议问题