📜  如何在训练模型时在 keras 中创建自定义回调函数 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:31.201000             🧑  作者: Mango

代码示例1
class myCallback(tf.keras.callbacks.Callback):
  def on_epoch_end(self, epoch, logs={}):
    if(logs.get('acc')>0.99):
      print("\nReached 99% accuracy so cancelling training!",epoch)
      self.model.stop_training = True
callback=myCallback()
model.fit(x_training, y_training,callbacks=[callback])