当前位置:网站首页>What is the difference between pytorch and tensorflow?
What is the difference between pytorch and tensorflow?
2022-06-13 00:45:00 【Program type】
PyTorch Is a fully functional framework for building deep learning models , meanwhile tensorflow It is also one of the commonly used frameworks . When we are studying , Try it for comparison . that pytorch and tensorflow What's the difference? ? Issues of concern , Here comes the answer .
pytorch and tensorflow What's the difference? ?
Creating and running a graph is probably the most different between the two frameworks . stay PyTorch in , The graph structure is dynamic , This means that diagrams are built at run time . And in the TensorFlow in , The graph structure is static , This means that the graph is first “ compile ” And then it runs again .
Let's take a simple example , stay PyTorch You can use the standard Python Write a grammar for Loop structure
for _ in range(T):
h = torch.matmul(W, h) + bhere T Can be changed every time the code is executed . and TensorFlow in , This requires the use of “ Control flow operation ” To build a graph , for example tf.while_loop.TensorFlow It does provide dynamic_rnn For common structures , But creating custom dynamic calculations is really more difficult .
PyTorch The simple graph structure in is easier to understand , what's more , And easier to debug . debugging PyTorch Code is like debugging Python code . You can use pdb And set breakpoints anywhere . debugging TensorFlow Code is not easy . Or you have to request the variables to be checked from the session , Or learn to use TensorFlow The debugger (tfdbg).

flexibility
tensorflow: Static calculation diagram , The data parameters are in CPU And GPU Migration between is troublesome , Debugging trouble
pytorch: Dynamic calculation diagram , The data parameters are in CPU And GPU Migration between is very flexible , Easy debugging
Calculation speed
Under the same conditions :
tensorflow stay CPU Upper running speed ratio pytorch fast
tensorflow stay GPU Running speed and pytorch almost
Dependency Library
tensorflow: Support more library functions , For example, there will be more image data preprocessing methods
pytorch: Expanding , The future and tensorflow It shouldn't be that different
Data loading
tensorflow:API Huge design , Use skillfully , But sometimes you can't load data directly into TensorFlow
pytorch:API The overall design is rough , But loading data API The design is very friendly . The interface for loading data consists of a data set 、 A sampler and a data loader constitute .
Equipment management
tensorflow: There's no need to manually adjust , Simple
pytorch: It is necessary to specify the enabled devices
On this point , By personal preference , I prefer to enable it manually CUDA_VISIBLE_DEVICES, My personal memory 、 The management of video memory is strict .
Share some of my artificial intelligence learning materials for free , Including some AI Common framework actual combat video 、 Image recognition 、OpenCV、NLQ、 machine learning 、pytorch、 Computer vision 、 Videos such as deep learning and neural network 、 Courseware source code 、 Famous essence resources at home and abroad 、AI Hot papers 、 Industry reports, etc .
For better systematic learning AI, I recommend that you collect one .
Here are some screenshots , Free download method is attached at the end of the article .
One 、 Artificial intelligence courses and projects

Two 、 Famous essence resources at home and abroad

3、 ... and 、 Collection of papers on artificial intelligence

Four 、 AI Industry Report

Learn Artificial Intelligence well , Read more , Do more , practice , If you want to improve your level , We must learn to settle down and learn slowly and systematically , Only in the end can we gain something .
Click on the business card below , Scan the code and download the information for free .
边栏推荐
- The origin of MySQL in bedtime stories
- Arduino controls tb6600 driver +42 stepper motor
- Arduino interrupt
- kotlin 协程withContext切换线程
- Hard (magnetic) disk (II)
- Arduino control tm1637 common positive four digit nixie tube
- 1. Google grpc framework source code analysis Hello World
- Triangle wave and triangle wave convolution
- Through MDC, you can easily track your scheduled task log
- AOF持久化
猜你喜欢

市值破万亿,连续三个月销量破10万,比亚迪会成为最强国产品牌?

Arduino control tm1637 common positive four digit nixie tube

Download nail live playback through packet capturing

高阶极点对于波形的影响

Use of split() method in string class
![Buuctf babyupload[gxyctf2019]](/img/e8/202298b64d8764355fad348b50fee6.png)
Buuctf babyupload[gxyctf2019]
![[gxyctf2019] no dolls -- detailed explanation](/img/c8/8c588ab8f58e2b38b9c64c4ccd733f.png)
[gxyctf2019] no dolls -- detailed explanation

Aunt learning code sequel: ability to sling a large number of programmers

什么是 Meebits?一个简短的解释

Kali system -- dnsrecon for DNS collection and analysis
随机推荐
硬(磁)盘(一)
Kotlin 协程挂起函数 suspend 关键字
Some basic design knowledge
[buglist] serial port programming does not read data
Development notes of Mongoose
Blinker FAQs
kotlin 协程withContext切换线程
[GYCTF2020]Ezsqli --BUUCTF
Go design concurrent web crawler
硬(磁)盘(二)
@Disallowcurrentexecution prevents quartz scheduled tasks from executing in parallel
阿姨学代码续集:能力吊打大批程序员
DNS attack surface analysis
Programming training 1
Static analysis of malicious code
Canvas game lower level 100
ROS2之OpenCV人脸识别foxy~galactic~humble
BUUCTF之BabyUpload[GXYCTF2019]
[sca-cnn interpretation] spatial and channel wise attention
Penetration test summary