TensorBoardが簡単に表示できるようになった!
今日のTwitterで見かけたので、試してみた!!!
Good news! TensorBoard now works in Jupyter Notebooks, via magic commands "%" that match the command line.
— Josh Gordon (@random_forests) 2019年2月26日
Example: https://t.co/5rtcpyhXSG pic.twitter.com/SceivzfrTJ
今まで(私個人の意見です)
from matplotlib import pyplot as plt # 精度のplot plt.plot(history.history['accuracy'], marker='.', label='accuracy') plt.plot(history.history['val_accuracy'], marker='.', label='val_accuracy') plt.title('model accuracy') plt.grid() plt.xlabel('epoch') plt.ylabel('accuracy') plt.legend(loc='best') plt.show() # 損失のplot plt.plot(history.history['loss'], marker='.', label='loss') plt.plot(history.history['val_loss'], marker='.', label='val_loss') plt.title('model loss') plt.grid() plt.xlabel('epoch') plt.ylabel('loss') plt.legend(loc='best') plt.show()
とか書いてた。(いつの間にか acc が accuracyに変わってた)
そして、こんな表示に。
これから(Colab上で楽々みるぞー)
これだ!!!
Graphももちろん!
ということで、やることは以下。
!pip install -q tf-nightly-2.0-preview # Load the TensorBoard notebook extension %load_ext tensorboard.notebook
からのログ出力先や、TensorBoardへのコールバック関数を用意
log_dir="logs/fit/" + datetime.datetime.now().strftime("%Y%m%d-%H%M%S") tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=1)
fit終わったら、これで起動!!!
%tensorboard --logdir logs/fit
便利!快適!