Keras + TensorFlow Realtime training chart

前端 未结 2 1083
误落风尘
误落风尘 2021-02-04 04:54

I have the following code running inside a Jupyter notebook:

# Visualize training history
from keras.models import Sequential
from keras.layers import Dense
impo         


        
2条回答
  •  死守一世寂寞
    2021-02-04 05:23

    Keras comes with a callback for TensorBoard.

    You can easily add this behaviour to your model and then just run tensorboard on top of the logging data.

    callbacks = [TensorBoard(log_dir='./logs')]
    result = model.fit(X, Y, ..., callbacks=callbacks)
    

    And then on your shell:

    tensorboard --logdir=/logs
    

    If you need it in your notebook, you can also write your own callback to get metrics while training:

     class LogCallback(Callback):
    
        def on_epoch_end(self, epoch, logs=None):
            print(logs["train_accuracy"])
    

    This would get the training accuracy at the end of the current epoch and print it. There's some good documentation around it on the official keras site.

提交回复
热议问题