当前位置:网站首页>With the advent of tensorflow 2.0, can pytoch still shake the status of big brother?
With the advent of tensorflow 2.0, can pytoch still shake the status of big brother?
2020-11-06 01:28:02 【Elementary school students in IT field】
List of articles
TensorFlow 2.0 preview
About TensorFlow 2.0 preview, Open source strategist at Google Edd Wilder-James An email that was to be made public introduced ,TensorFlow 2.0 The preview will be officially released this year , And called it a major milestone . Will focus on ease of use , and Eager Execution Will be TensorFlow 2.0 Core functions .
notes :“Eager Execution” It's an imperative 、 Interface defined by run , Once from Python Called to perform the operation immediately , This makes
TensorFlow It's easier to get started with , It also makes R & D more intuitive .
TensorFlow 2.0 go online
TensorFlow 2.0 preview Finally online , It seems that the stable version is not too far away from us —— Officially, it will be the first quarter of the year .
Google said , In the last few years ,TensorFlow Added a lot of components . adopt TensorFlow 2.0 A massive reconstruction of the version , These functions will be packaged into an integrated platform , Support the entire machine learning workflow from training to deployment . The figure below shows briefly TensorFlow 2.0 The new architecture of :
Note: Although the training section above focuses on Python API, however TensorFlow.js It also supports training models .TensorFlow 2.0 There is also varying degrees of support for other languages , Include Swift、R Language and Julia.
Market share
The global situation
2.0 The press conference also put TensorFlow My current background has been revealed : at present TF There have been more than 4100 Million downloads , The community has more than 1800 Multiple contributors .
A global map will be displayed at the press conference , But there is no disclosure about the Chinese community , How can this be ?
Official picture
An overview of China
Here is my Chinese search engine – Baidu index statistics through the search data to observe the two mainstream deep learning framework tensorflow And pytorch The change of , The results are as follows :
The picture above shows the two mainstream frameworks of deep learning in China in the past year tensorflow And pytorch Contrast between , It is obvious that
tensorflow Far better than pytorch. Especially in the presence of TF2.0 After the announcement , The search index gap has widened .
from Crowd attributes Come up and say 20~29 as well as 30-39 Between the crowd , Younger people are more likely to pytorch, Older programmers are more inclined to tensorflow.
TensorFlow And PyTorch difference
-
Installation environment
First of all, support on the system :all in . But it's worth noting that 2018Pytorch v0.4.0 Support windows Platform . -
CPU and GPU
TensorFlow Targeted CPU and GPU Install the module , and PyTorch Don't like TensorFlow The same has been specified CPU and GPU, If you want to support GPU and CPU, More code will be generated . -
setup script
be based on Anaconda Both of the two deep learning modules can be directly passed through Pip To install . -
Whether it's suitable for beginners
TensorFlow 1.x And PyTorch By contrast , Personally think that PyTorch many , But in tensorflow 2.0 After release, according to its new features ,Tensorflow 2.0 Will be in PyTorch Be roughly the same .
The following is a comparison of some specific aspects :
PyTorch And TensorFlow 1
For example, to calculate 1 + ½ + ¼ + ⅛ + … , Use PyTorch The code is obviously better than TensorFlow Simple :
Later from TensorFlow 1.4 Start , You can choose to start eager Pattern .
stay TensorFlow 2.0, eager execution By default , It doesn't need to be enabled :
You can find eager Patterns and PyTorch It's as simple as .
- In effect
I think it's for different needs 、 Different algorithms have different choices , There is no absolute good or bad .
TensorFlow2.0 New characteristics
Let's take a look at 2.0 New features of version :2.0 The version is simple 、 Clearer 、 Three characteristics of expansibility , Greatly simplify API; Improved TensorFlow Lite and TensorFlow.js The ability to deploy models ;
TensorFlow2.0 Alpha To sum up, i.e :
- Easier to use :
Such as tf.keras Wait for advanced API Will be easier to use ; also Eager execution Will be the default setting .
- Clearer :
Removed duplicate features ; Different API Call syntax is more consistent 、 intuitive ; Better compatibility .
- More flexible :
Provide complete low level API; Can be found in tf.raw_ops Access internal operations ; Provide variables 、checkpoint Inheritable interfaces to and layers .
A brief summary of the main changes
-
API clear
many API stay TF 2.0 To disappear or move . Some of the major changes include the deletion of tf.app,tf.flags And tf.logging, Open source support absl-py(Google Their own Python The code base ). -
Eager Execution Will become the core function
Probably TensorFlow 2.0 The most obvious change is to make Eager execution As the default priority mode . This means that any operation will run immediately after the call , We no longer need to predefine static diagrams , Re pass 「tf.Session.run()」 All parts of the executive chart .
# TensorFlow 1.X
outputs = session.run(f(placeholder), feed_dict={placeholder: input})
# TensorFlow 2.0
outputs = f(input)
- Code style with Keras Mainly
Many functions such as optimizer,loss,metrics Will be integrated into Keras in
- Support more platforms and languages
1.0 To 2.0 transition
Automatic transition
About code conversion : from TensorFlow1.0 To 2.0 Transition we use pip install TensorFlow 2.0 when , The system will automatically add tf_upgrade_v2( project Address ) , It can take the existing TensorFlow Python Code conversion to TensorFlow 2.0 Code .
# Usage method :
!tf_upgrade_v2
# choice input file, Output output file
tf_upgrade_v2 --infile foo.py --outfile foo-upgraded.py
# Transform the entire directory
tf_upgrade_v2 --intree coolcode --outtree coolcode-upgraded
Compatibility
To ensure TensorFlow 2.0 Still support your code , The upgrade script contains a compat.v1 modular . This module replaces TF
1.x Symbol tf.foo, Equivalent to tf.compat.v1.foo The reference is the same . Although the compatibility module is very good , But we recommend that you manually proofread the replacement and migrate it to tf. New in the namespace API, instead of tf.compat.v1..because TensorFlow
2.x Module is obsolete ( for example ,tf.flags and tf.contrib), So switch to compat.v1 Some can't fix changes . Upgrading this code may require the use of other libraries ( for example absl.flags) Or switch to tensorflow
/ addons In the package .
The above is from the official website
Summary
TensorFlow 2.0 A very powerful and mature deep learning library has been simplified , The point is to keras Mainly , I wonder if you understand keras, According to the official slogan , It is “ Design for human beings , It's not designed for machines API”. So he will be greatly optimized in terms of entry , If you have the following needs , that TensorFlow Is a good choice :
- Develop models that need to be deployed on mobile platforms
- Want rich learning resources in various forms (TensorFlow There are many development courses )
- Want or need to use Tensorboard
- Large scale distributed model training is needed
PyTorch Still a young framework , But it's growing faster and faster . If you have the following needs , It might be better for you :
- Rapid prototyping for small scale projects
- To study
reference
https://github.com/tensorflow/docs/blob/master/site/en/r2/guide/effective_tf2.md
https://tensorflow.google.cn/
https://www.youtube.com/watch?v=WTNH0tcscqo&t=304s

版权声明
本文为[Elementary school students in IT field]所创,转载请带上原文链接,感谢
边栏推荐
- C++ 数字、string和char*的转换
- C++学习——centos7上部署C++开发环境
- C++学习——一步步学会写Makefile
- C++学习——临时对象的产生与优化
- C++学习——对象的引用的用法
- C++编程经验(6):使用C++风格的类型转换
- Won the CKA + CKS certificate with the highest gold content in kubernetes in 31 days!
- C + + number, string and char * conversion
- C + + Learning -- capacity() and resize() in C + +
- C + + Learning -- about code performance optimization
猜你喜欢
-
C + + programming experience (6): using C + + style type conversion
-
Latest party and government work report ppt - Park ppt
-
在线身份证号码提取生日工具
-
Online ID number extraction birthday tool
-
️野指针?悬空指针?️ 一文带你搞懂!
-
Field pointer? Dangling pointer? This article will help you understand!
-
HCNA Routing&Switching之GVRP
-
GVRP of hcna Routing & Switching
-
Seq2Seq实现闲聊机器人
-
【闲聊机器人】seq2seq模型的原理
随机推荐
- LeetCode 91. 解码方法
- Seq2seq implements chat robot
- [chat robot] principle of seq2seq model
- Leetcode 91. Decoding method
- HCNA Routing&Switching之GVRP
- GVRP of hcna Routing & Switching
- HDU7016 Random Walk 2
- [Code+#1]Yazid 的新生舞会
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- HDU7016 Random Walk 2
- [code + 1] Yazid's freshman ball
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- Qt Creator 自动补齐变慢的解决
- HALCON 20.11:如何处理标定助手品质问题
- HALCON 20.11:标定助手使用注意事项
- Solution of QT creator's automatic replenishment slowing down
- Halcon 20.11: how to deal with the quality problem of calibration assistant
- Halcon 20.11: precautions for use of calibration assistant
- “十大科学技术问题”揭晓!|青年科学家50²论坛
- "Top ten scientific and technological issues" announced| Young scientists 50 ² forum
- 求反转链表
- Reverse linked list
- js的数据类型
- JS data type
- 记一次文件读写遇到的bug
- Remember the bug encountered in reading and writing a file
- 单例模式
- Singleton mode
- 在这个 N 多编程语言争霸的世界,C++ 究竟还有没有未来?
- In this world of N programming languages, is there a future for C + +?
- es6模板字符
- js Promise
- js 数组方法 回顾
- ES6 template characters
- js Promise
- JS array method review
- 【Golang】️走进 Go 语言️ 第一课 Hello World
- [golang] go into go language lesson 1 Hello World