Keras键盘中断停止训练?

Joh*_*han 7 deep-learning keras

似乎有一种方法可以在tensorflow中执行:键盘中断tensorflow运行并保存在该点

在Keras有类似的东西吗?

rvi*_*nas 8

您可以捕获KeyboardInterrupt异常并将模型保存在except块中:

save_path = './keras-saves/_lastest.ckpt'
try:
    model.fit(x_train, y_train,
              batch_size=batch_size,
              epochs=epochs)
except KeyboardInterrupt:
    model.save(save_path)
    print('Output saved to: "{}./*"'.format(save_path))
Run Code Online (Sandbox Code Playgroud)