当前位置:网站首页>Tensorboard quick start (pytoch uses tensorboard)
Tensorboard quick start (pytoch uses tensorboard)
2022-07-03 17:23:00 【iioSnail】
List of articles
TensorBoard brief introduction
TensorBoard yes Google Developed a machine learning visualization tool . It is mainly used to record the machine learning process , for example :
- Record Loss change 、 Accuracy changes etc.
- Record The picture changes 、 phonological change 、 Text changes, etc , For example, doing GAN when , You can record a generated picture after a period of time
- Draw a model
Please refer to Official documents
TensorBoard Interface is introduced

TensorBoard install
Use it directly pip Can be installed :
pip install tensorboard
After installation , Enter at the command line :
tensorboard --help
If it can output normally , The installation is successful .
TensorBoard function
Just run the start command :
tensorboard --logdir my_log
my_log yes TensorBoard Of log Directory of files .Tensorboard The data displayed in the panel comes from log file , Generally, a complete run generates one log file .
for example , stay Pytorch in , We will call new One SummaryWriter object , A log file , Then we will call it add_something Method , Go to log Write a log inside , After the TensorBoard You can see the data in the panel . Finally, after the training , call close Method end .
If you see the following output , Indicating successful startup :
TensorBoard 2.8.0 at http://localhost:6006/ (Press CTRL+C to quit)
At this time, you only need to enter http://localhost:6006/ You can enter TensorBoard Interface .
Pytorch Use TensorBoard
Pytorch Use Tensorboard There are three main uses API:
SummaryWriter: This is used to create a log file ,TensorBoard When viewing the panel , You also need to select the one to view log file .add_something: towards log Add data to the file . For example, throughadd_scalarAdd line chart data ,add_imageYou can add pictures .close: When the training is over , We can go throughcloseMethod end log write in .
Next , Let's simulate the change of accuracy during training .
The first thing you need to new One SummaryWriter object :
from torch.utils.tensorboard import SummaryWriter
writer = SummaryWriter(log_dir='runs/mock_loss')
After running this line of code , You can see that a runs/mock_accuracy Folder , And it has event journal 
Now it's ready to start tensorboard Here we are :
tensorboard --logdir runs
Now enter tensorboard After the page , I can't see anything , Because we haven't told log Write any data inside :

Next use add_scalar Draw a line chart of accuracy :
for i in range(100):
writer.add_scalar(tag="accuracy", # It can be temporarily understood as the name of the image
scalar_value=i * random.uniform(0.8, 1), # The value of the ordinate
global_step=i # What is the current iteration , It can be understood as the value of abscissa
)
time.sleep(2 * random.uniform(0.5, 1.5))
Simulation here 1~3 Complete an iteration in seconds and calculate the accuracy , Then add the accuracy to accuracy Below this figure .
After a while , Let's refresh the page , You can see our accuracy curve :

Because the data is still being written , So the curve is still changing .
Tensor Broken line diagram (Scalars)

- TODO: Introduction of other graphics
边栏推荐
- Javescript variable declaration -- VaR, let, const
- [try to hack] active detection and concealment technology
- Where is the monitoring page of RDS database?
- 【RT-Thread】nxp rt10xx 设备驱动框架之--Audio搭建和使用
- SSH连接远程主机等待时间过长的解决方法
- Examination questions for the assignment of selected readings of British and American Literature in the course examination of Fujian Normal University in February 2022
- TensorBoard快速入门(Pytorch使用TensorBoard)
- 【RT-Thread】nxp rt10xx 设备驱动框架之--Pin搭建和使用
- One brush 142 monotone stack next larger element II (m)
- Hongmeng third training
猜你喜欢
![Luogu: p2685 [tjoi2012] Bridge](/img/f5/f77027288a211ae466781b09ce650f.jpg)
Luogu: p2685 [tjoi2012] Bridge

鸿蒙第三次培训

Unity notes unityxr simple to use

vs2013已阻止安装程序,需安装IE10

Leetcode: lucky number in matrix

Notes on problems -- watching videos on edge will make the screen green

国内如何购买Google Colab会员

Collection of the most beautiful graduation photos in the graduation season, collection of excellent graduation photos

鸿蒙第四次培训

kubernetes资源对象介绍及常用命令(五)-(NFS&PV&PVC)
随机推荐
Define a structure fraction to represent a fraction, which is used to represent fractions such as 2/3 and 5/6
University of Electronic Science and technology, accounting computerization, spring 20 final exam [standard answer]
List of financial products in 2022
【JokerのZYNQ7020】DDS_ Compiler。
[RT thread] NXP rt10xx device driver framework -- RTC construction and use
SVN完全备份svnadmin hotcopy
Where is the monitoring page of RDS database?
One brush 147-force deduction hot question-4 find the median of two positive arrays (H)
人生还在迷茫?也许这些订阅号里有你需要的答案!
Kotlin learning quick start (7) -- wonderful use of expansion
[RT thread] NXP rt10xx device driver framework -- pin construction and use
SWM32系列教程4-端口映射及串口应用
网络硬盘NFS的安装与配置
An example of HP array card troubleshooting
C语言字符串反转
Life is still confused? Maybe these subscription numbers have the answers you need!
Kubernetes resource object introduction and common commands (4)
29: Chapter 3: develop Passport Service: 12: develop [obtain user account information, interface]; (use VO class to package the found data to meet the requirements of the interface for the returned da
[try to hack] active detection and concealment technology
IntelliJ 2021.3 short command line when running applications