Brief introduction to the use of Tensorboard

Tensorboard is a visualization tool with very, very many functions, and it is very very simple to implement, which can help us to view

  • The progress of model training, such as loss and acc (used in the classification network, only look at loss in target detection)
  • Weight histogram
  • Gradient histogram
  • The structure of the entire model

specific methods:

1. Import tensorboard in the library of the callback function

from keras.callbacks import TensorBoard

2. Create a TensorBoard before training the model. These TensorBoards need to specify some parameters. You can specify the callbacks parameters in fit during training:

  Tensorboard= TensorBoard(log_dir="./model", histogram_freq=1,write_grads=True)
  history=model.fit·····	

There are 7 commonly used parameters:

  • 1. log_dir: The location used to save Tensorboard log files and other content
  • 2. histogram_freq: Calculate the frequency of activation value and model weight histogram for each layer in the model.
  • 3. write_graph: Whether to visualize the image in TensorBoard (whether to draw the model's picture).
  • 4. write_grads: Whether to visualize the histogram of gradient values ​​in TensorBoard.
  • 5. batch_size: The input batch size of the afferent neuron network used for histogram calculation.
  • 6. write_images: Whether to visualize the model weights as pictures in TensorBoard.
  • 7. update_freq: The three commonly used values ​​are'batch','epoch' or integers. When
    using'batch', write the loss and evaluation value into TensorBoard after each batch . 'epoch' is similar. If an integer is used, the loss and evaluation value will be written into
    TensorBoard after every certain number of samples .

Show off

  • Navigate to the location where the model file is saved

  • Open the cmd terminal and cd to the upper level directory of the model file

  • Execute the following command in the upper level directory of the model folder: tensorboard --logdir=./model, press Enter to automatically load the URL

  • Copy the URL and open the visual interface in Firefox or Google browser

Guess you like

Origin blog.csdn.net/qq_42308217/article/details/110855239