当前位置:网站首页>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 .
边栏推荐
- [error] invalid use of incomplete type uses an undefined type
- Three kinds of thinking make me reborn
- 【北亚服务器数据恢复】虚拟机文件丢失导致Hyper-V服务瘫痪的数据恢复案例
- BUUCTF之BabyUpload[GXYCTF2019]
- Programming training 1
- 生物解锁--指纹录入流程
- 6.824 Lab 4B: Sharded Key/Value Service
- ucore lab2
- Paper reading and sharing
- 天津银行周传凯:从 0 到 1,我的分布式数据库落地经验谈
猜你喜欢
随机推荐
[network protocol] problems and solutions in the use of LwIP
MySQL queries the quantity of each month and the year-on-year and month on month data of each month
Use of split() method in string class
[CISCN2019 华北赛区 Day2 Web1]Hack World --BUUCTF
Zhouchuankai, Bank of Tianjin: from 0 to 1, my experience in implementing distributed databases
Using com0com/com2tcp to realize TCP to serial port (win10)
BUUCTF之BabySQL[极客大挑战 2019]
A simple deadlock example
Learning and Development notes of mongdb
Mongodb array operation
6.824 Lab 3A: Fault-tolerant Key/Value Service
Summary of openstack installation problems
Through MDC, you can easily track your scheduled task log
[sca-cnn interpretation] spatial and channel wise attention
ImportError: cannot import name ' get_ ora_ doc' from partially initialized module
Mysql批量插入数据时如何解决重复问题?
Delphi2009 connecting Oracle11g
Also on STM32 using dma+ serial port to obtain variable length data
高阶极点对于波形的影响
pytorch是什么?解释pytorch的基本概念


![[MRCTF2020]Ez_bypass --BUUCTF](/img/73/85262c048e177968be67456fa4fe02.png)
![Buuctf's babysql[geek challenge 2019]](/img/6c/957e5e09f252210d0b4cf8771d4ade.png)





