当前位置:网站首页>Pytorch uses tensorboard to realize visual summary
Pytorch uses tensorboard to realize visual summary
2022-07-25 13:58:00 【Apple sister】
One 、 Introduce :
Tensorboard yes TensorFlow An additional tool for , Can record the number of training process 、 Images, etc , To facilitate researchers to observe the neural network training process . But for PyTorch Other neural network training frameworks have no functions like Tensorboard Similar tools as comprehensive , Some existing tools have limited functions or are difficult to use (tensorboard_logger, visdom etc. ) .TensorboardX This tool makes TensorFlow Other neural network frameworks can also be used Tensorboard The convenience function of . notes :pytorch 1.1.0 Future native support tensorboard, No installation required tensorboardX
Two 、 Environmental preparation :
This process is cumbersome , It has gone through the following steps :
1. The model is in docker Running in , It's set up tensorboardx and pytorch etc. , but docker There is no graphical interface , Can't use google-chrome(tensorboardx Give a link , To view in the default browser , Online recommendation chrome, Be careful tensorboard and chrome Must be used in the same environment !)
2. Try to docker Install on the server chrome, success , The method is to download chrome The installation files (google-chrome-stable_current_amd64.deb) Format to local , Install again , Such as :
sudo dpkg -i google-chrome-stable_current_amd64.deb
open chrome command :/usr/bin/google-chrome
3. Only python2.7 Environmental Science ( function tensorboardX Will report a mistake ), Equipped with python3.7、tensorflow、tensorboardX. install python:https://blog.csdn.net/m0_37814112/article/details/103039263, The other two use pip Can be installed ( If it doesn't work, be patient and try several times ) Pay attention to python3.7 The path of maps to the default python route
4. After successful installation , Enter the command tensorboard --logdir yourpath,yourpath It's for storage. tensorboard Directory of output files , It will be a pile events file , If successful, display a website :http://localhost:6006/,IP And port number can be set , If there is garbled code, it is definitely unsuccessful .
This process should also be possible in windows Of chrome Project to the server environment to operate , But I didn't try .
3、 ... and 、pytorch Specific usage in :
Here is mainly used to save training and verification loss diagram 、 Input and output pictures at each step .
1. Import summarywriter package
from tensorboardX import SummaryWriter
pytorch1.1.0 above :
from torch.utils.TensorBoard import SummaryWriter
2. branch train and val Two modes , And set the address ( Multi card training is set to 0 Number cuda Output )
self.writers = {}
if self.rank == 0:
for mode in ["train", "val"]:
self.writers[mode] = SummaryWriter(os.path.join(self.log_path, mode))
3. Set every certain number of batch Save at the end loss( You can also save others ), Simultaneous recording step
writer = self.writers[mode]
for l, v in losses.items():
writer.add_scalar("{}".format(l), v, self.step)
If you need to save pictures , Save as needed
writer.add_image(
"color_{}_{}/{}".format(frame_id, s, j),
inputs[("color", frame_id, s)][j].data, self.step)
4. Close it after training summarywriter:
if len(self.writers) != 0:
self.writers['train'].close()
self.writers['val'].close()
Four 、 Effect display :( Can be displayed separately train and val Visualization )
loss visualization : Move the mouse to see each step Specific data , You can also see the saved pictures and other information 
边栏推荐
- Construction and practice of yolov7 in hands-on teaching
- 百度搜索打击盗版网文站点,SEOer应该关注哪些问题?
- Engineering monitoring multi-channel vibrating wire sensor wireless acquisition instrument external digital sensor process
- Error of Tencent cloud [100007] this env is not enable anonymous login
- Canal realizes MySQL data synchronization
- Application engineering safety monitoring of wireless vibrating wire acquisition instrument
- leetcode1 --两数之和
- From input URL to web page display
- Numpy quick start
- Int array get duplicate data
猜你喜欢

word设置粘贴仅保留文本

Business data analysis of CDA level1 knowledge point summary

Engineering monitoring multi-channel vibrating wire sensor wireless acquisition instrument external digital sensor process

Tm1637 four digit LED display module Arduino driver with second dot

刷题-洛谷-P1047 校门外的树

Construction and practice of yolov7 in hands-on teaching

Okaleido launched the fusion mining mode, which is the only way for Oka to verify the current output

Working principle of Lora to 4G and gateway repeater
![Serious [main] org.apache.catalina.util.lifecyclebase Handlesubclassexception initialization component](/img/39/6f6760e80acec0b02028ea2ed1a5b1.png)
Serious [main] org.apache.catalina.util.lifecyclebase Handlesubclassexception initialization component

Pytest.mark.parameterize and mock use
随机推荐
MXNet对DenseNet(稠密连接网络)的实现
Day1:三种语言暴刷牛客130题
Business analysis report and data visualization report of CDA level1 knowledge point summary
Brush questions - Luogu -p1146 coin flip
wangeditor 富文本编辑器
Numpy quick start
【Platform IO编译Hifive1-revB】*** [.pio\build\hifive1-revb\src\setupGPIO.o] Error 1的解决办法
NoSQL, relational database, row and column database comparison and analogy
命名空间与库
NoSQL,关系型数据库,行列数据库对比、类比
Dr. Berkeley's "machine learning engineering" big truth; AI vice president '2022 ml job market' analysis; Large list of semiconductor start-ups; Large scale video face attribute data set; Cutting edge
AQS of concurrent programming
adb通过Wi-Fi连接小米手机
Pytest.mark.parameterize and mock use
Tm1637 four digit LED display module Arduino driver with second dot
Engineering monitoring multi-channel vibrating wire sensor wireless acquisition instrument external digital sensor process
OKA通证权益解析,参与Okaleido生态建设的不二之选
@Wrap decorator
NUC980 设置SSH Xshell连接
"Digital security" alert NFT's seven Scams