Use TensorBoard for visualization experiment result in machine learning

Prepare development environment: Python 3.9.6 ; pip 21.1.3 ; jupyter-notebook 6.4.0 ; tensorflow 2.5.0 . If you run by command line Create file tensorboard_pytorch.py from torch.utils.tensorboard import SummaryWriter writer = SummaryWriter()for x inrange(5): y =100* x writer.add_scalar('y', y, x) writer.close() (c1) Result is Use your web browser, go to address http://localhost:6006 to see the result

Prepare development environment: Python 3.9.6 ; pip 21.1.3 ; jupyter-notebook 6.4.0 ; tensorflow 2.5.0 .

If you run by command line

Create file tensorboard_pytorch.py

from torch.utils.tensorboard import SummaryWriter

writer = SummaryWriter()for x inrange(5):
    y =100* x
    writer.add_scalar('y', y, x)

writer.close()

(c1)

Result is

Use your web browser, go to address http://localhost:6006 to see the result

If you run by jupyter notebook

Create a new jupyter notebook

pin install jupyter
jupyter notebook

Code block is the same, the content is

from torch.utils.tensorboard import SummaryWriter

writer = SummaryWriter()for x inrange(5):
    y =100* x
    writer.add_scalar('y', y, x)

writer.close()

(c1)

Load extension TensorBoard by

%load_ext tensorboard

Visualize the result of code snippet (c1) by

%tensorboard --logdir ./runs/

Result is

SummaryWriter methods are:

  • add_scalar
  • add_scalars
  • add_custom_scalars
  • add_historgram
  • add_image
  • add_images
  • add_figure
  • add_video
  • add_audio
  • add_text

Nguồn: viblo.asia

Bài viết liên quan

Tấn Công Ứng Dụng Web: Mối Đe Dọa Hàng Đầu – Phần 2

viết lại nội dung này ” Phát hiện các cuộc tấn công Cross Site Scripting (XSS)

AI Chatbot 2025: Xu Hướng Tất Yếu Cho Doanh Nghiệp Dẫn Đầu

Giới thiệu AI chatbots đã trải qua một hành trình đáng kể, từ những công cụ t

Tấn Công Ứng Dụng Web: Mối Đe Dọa Hàng Đầu – Phần 1

Tấn công web là gì? Ứng dụng web là các ứng dụng cung cấp dịch vụ cho người

SEO Mũ Trắng, Mũ Đen, Mũ Xám: Hiểu Biết và Lựa Chọn Phù Hợp

SEO Mũ Trắng, Mũ Đen, Mũ Xám: Hiểu Biết và Lựa Chọn Phù Hợp Trong kỷ nguyên s