当前位置:网站首页>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_scalar
Add line chart data ,add_image
You can add pictures .close
: When the training is over , We can go throughclose
Method 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
边栏推荐
- 【RT-Thread】nxp rt10xx 设备驱动框架之--hwtimer搭建和使用
- 绝对定位时元素水平垂直居中
- 【Try to Hack】主动侦查隐藏技术
- [UE4] brush Arctic pack high quality Arctic terrain pack
- Golang unit test, mock test and benchmark test
- Electronic technology 20th autumn "Introduction to machine manufacturing" online assignment 3 [standard answer]
- Assignment examination questions of advanced English (III) for the course examination of Fujian Normal University in February 2022
- Pools de Threads: les composants les plus courants et les plus sujets aux erreurs du Code d'affaires
- Stm32h7 Hal library SPI DMA transmission has been in busy solution
- Depth first search of graph
猜你喜欢
Life is still confused? Maybe these subscription numbers have the answers you need!
29:第三章:开发通行证服务:12:开发【获得用户账户信息,接口】;(使用VO类包装查到的数据,以符合接口对返回数据的要求)(在多处都会用到的逻辑,在Controller中可以把其抽成一个共用方法)
1164 Good in C
New library online | cnopendata complete data of Chinese insurance institution outlets
Pools de Threads: les composants les plus courants et les plus sujets aux erreurs du Code d'affaires
Qt调节Win屏幕亮度和声音大小
Cross border e-commerce: advantages of foreign trade enterprises in overseas social media marketing
One brush 147-force deduction hot question-4 find the median of two positive arrays (H)
鸿蒙第三次培训
How to read the source code [debug and observe the source code]
随机推荐
Kubernetes resource object introduction and common commands (III)
基于主机的入侵系统IDS
设计电商秒杀
Solution to long waiting time of SSH connection to remote host
Where is the database account used when running SQL tasks in data warehouse tasks configured
Apache服务挂起Asynchronous AcceptEx failed.
New library online | cnopendata China bird watching record data
PHP online confusion encryption tutorial sharing + basically no solution
RDS数据库的监测页面在哪看?
[combinatorics] recursive equation (special solution form | special solution solving method | special solution example)
RedHat 6.2 配置 Zabbix
Luogu: p1155 [noip2008 improvement group] double stack sorting (bipartite graph, simulation)
2021 ICPC regional competition (Shanghai) g.edge groups (tree DP)
定义一个结构体Fraction,表示分数,用于表示 2/3, 5/6这样的分数
The difference between get and post
跨境电商:外贸企业做海外社媒营销的优势
Golang unit test, mock test and benchmark test
Rsync remote synchronization
Rsync远程同步
Electronic Science and technology 20th autumn "Microcomputer Principle and application" online assignment 2 [standard answer]