Saving best model in keras

后端 未结 3 1071
隐瞒了意图╮
隐瞒了意图╮ 2020-12-29 20:22

I use the following code when training a model in keras

from keras.callbacks import EarlyStopping

model = Sequential()
model.add(Dense(100, activation=\'rel         


        
3条回答
  •  旧时难觅i
    2020-12-29 21:07

    I guess model_2.compile was a typo. This should help if you want to save the best model w.r.t to the val_losses -

    checkpoint = ModelCheckpoint('model-{epoch:03d}-{acc:03f}-{val_acc:03f}.h5', verbose=1, monitor='val_loss',save_best_only=True, mode='auto')  
    
    model.compile(optimizer='adam', loss='mean_squared_error', metrics=['accuracy'])
    
    model.fit(X, y, epochs=15, validation_split=0.4, callbacks=[checkpoint], verbose=False)
    

提交回复
热议问题