TensorBoard is used to visualize graphical
and other tools to understand, debug, and optimize the model's interface.
It is a tool that provides measurement and visualization for machine learning workflows.
It helps in tracking metrics such as loss and accuracy, model graph visualization, and item embedding in low-dimensional space.
In the following, we use the image classification model for MNIST data , which will first import the required libraries and load the dataset.
The model is built using the simplest sequential model
import tensorflow as tf (X_train, y_train), (X_test, y_test) = .load_data() from import np_utils X_train=X_train.astype('float32') X_test=X_test.astype('float32') X_train/=255 X_test/=255 X_train = X_train.reshape(X_train.shape[0], 28, 28, 1).astype('float32') X_test = X_test.reshape(X_test.shape[0], 28, 28, 1).astype('float32') y_train = np_utils.to_categorical(y_train, 10) y_test = np_utils.to_categorical(y_test, 10) model = Sequential() (Convolution2D(32, 3, 3, input_shape=(28, 28, 1))) (Activation('relu')) (Dropout(0.25)) (Convolution2D(32, 3, 3)) (Activation('relu')) (Convolution2D(32, 3, 3)) (Activation('relu')) (Dropout(0.25)) (Flatten()) (Dense(128)) (Dense(128)) (Activation('relu')) (Dense(10)) (Activation('softmax')) (loss='categorical_crossentropy',optimizer='adam',metrics=['accuracy'])
When the keras API trains a model, the
A tensorboard callback is created
to ensure that the metrics are recorded in the specified directory.
Save here tologs/fit
import datetime !rm -rf ./logs/ log_dir = "logs/fit/" + ().strftime("%Y%m%d-%H%M%S") tensorboard_callback=(log_dir=log_dir, histogram_freq=1) (x=X_train, y=y_train,epochs=30,validation_data=(X_test, y_test), callbacks=[tensorboard_callback])
If you use thecolab
The use of terminals is not supported.
For Windows users:tensorboard --logdir= logs/fitg
Tensorboard is located at: http://localhost:6006
If using colab, you need to load the TensorBoard extension
%load_ext tensorboard %tensorboard --logdir logs/fit from tensorboard import notebook (port=6006, height=1000)
If training iterations 5k to 55k, the
TensorBoard will give approximate results for the test set
If you are using TensorBoard in torch, with the release of PyTorch version 1.8.1, you need to use the PyTorch Profiler.
Requires installationtorch_tb_profiler
。
torch_tb_profiler
beTensorBoard
A plugin that visualizes the GPU of the
Refer to the official tutorial
/tutorials/intermediate/tensorboard_profiler_tutorial.html
/pytorch/kineto/tree/main/tb_plugin
To this article on the white beginner to learn TensorBoard visual model training article is introduced to this, more related TensorBoard visual model training content please search for my previous articles or continue to browse the following related articles I hope you will support me more in the future!