Python/Keras - Creating a callback with one prediction for each epoch

前端 未结 1 1683
生来不讨喜
生来不讨喜 2021-02-09 06:12

I\'m using Keras to predict a time series. As standard I\'m using 20 epochs. I want to know what did my neural network predict for each one of the 20 epochs.

By using mo

相关标签:
1条回答
  • 2021-02-09 06:53

    You are overwriting the prediction for each epoch, that is why it doesn't work. I would do it like this:

    class prediction_history(Callback):
        def __init__(self):
            self.predhis = []
        def on_epoch_end(self, epoch, logs={}):
            self.predhis.append(model.predict(predictor_train))
    

    This way self.predhis is now a list and each prediction is appended to the list at the end of each epoch.

    0 讨论(0)
提交回复
热议问题