ch16
foldertf_env
is activated: conda activate tf_env
logs
in which your deep-learning models will write info to visualizetensorboard --logdir=logs
http://localhost:6006
logs
folder, it loads the data into the dashboard: SCALARS
tabacc
), training loss (loss
), validation accuracy (val_acc
) and validation loss (val_loss
) MNIST_CNN_TensorBoard.ipynb
MNIST_CNN.ipynb
notebook in JupyterLab’s File Browser
tab and select Duplicate
to make a copy of the notebook MNIST_CNN-Copy1.ipynb
, then select Rename
, enter the name MNIST_CNN_TensorBoard.ipynb
and press Enterfit
the model, you need to configure a TensorBoard
object (module tensorflow.keras.callbacks
), which the model will use to write data into a specified folder that TensorBoard monitorsfit
method, then type a to add a new code cell above the current cell (use b
for below)TensorBoard
objectfrom tensorflow.keras.callbacks import TensorBoard
import time
tensorboard_callback = TensorBoard(log_dir=f'./logs/mnist{time.time()}',
histogram_freq=1, write_graph=True)
log_dir
—folder in which this model’s log files will be written. Creating a name based on the time ensures that each new execution of the notebook will have its own log folderhistogram_freq
—The frequency in epochs that Keras will output to the model’s log files (every epoch in this case)write_graph=True
—Output a graph of the model, which you can view in TensorBoard's GRAPHS tab fit
¶fit
method callcallbacks
argument, which is a list of callback objects:cnn.fit(X_train, y_train, epochs=10, batch_size=64,
validation_split=0.1, callbacks=[tensorboard_callback])
©1992–2020 by Pearson Education, Inc. All Rights Reserved. This content is based on Chapter 5 of the book Intro to Python for Computer Science and Data Science: Learning to Program with AI, Big Data and the Cloud.
DISCLAIMER: The authors and publisher of this book have used their best efforts in preparing the book. These efforts include the development, research, and testing of the theories and programs to determine their effectiveness. The authors and publisher make no warranty of any kind, expressed or implied, with regard to these programs or to the documentation contained in these books. The authors and publisher shall not be liable in any event for incidental or consequential damages in connection with, or arising out of, the furnishing, performance, or use of these programs.