TensorFlow2.0和Pytorch发展以及选择

近两年来,Google和Facebook等秉持开源理念,推动着AI工程工具越来越强大

最近由于学术进程,一方面Pytorch越来越多地开始用于学术中来,另一方面 之前的模型都是基于tensorflow1.x的,而且TensorFlow2.0升级迭代似乎受到了较多的负面评价.

所以,现在通过对于工程框架来龙去脉的了解,进一步明晰每个框架的优缺点,预测未来需要掌握和使用的框架.主力攻克一个框架,辅助灵活框架,快速迭代学术代码开发过程.

前世今生

TensorFlow发展历程

Google Jeff发布版本历程:

TensorFlow2.0和Pytorch发展以及选择

2015年同类型框架有:

TensorFlow2.0和Pytorch发展以及选择
Apacha孵化项目:新加坡国立大学 SINGA.
TensorFlow2.0和Pytorch发展以及选择

发展

TensorFlow2.0和Pytorch发展以及选择

2017年

TensorFlow从测试版本 变位1.0正式版本
分解到三个
增加 tfdbg
同时有了PyTorch0.1版本
TensorFlow2.0和Pytorch发展以及选择

  • 比较TensorFlow1.x风格 VS PyTorch
    TensorFlow2.0和Pytorch发展以及选择

  • TensorFlow2017年有以下不好方面,PyTorch因为有了0.1版本,所以有一些学者 转向了Pytorch
    TensorFlow2.0和Pytorch发展以及选择

2019TensorFlow2.0 is coming

  • 去掉了session概念,分支控制去掉自己if else 等自己命名体系,而没用python的代码.
    TensorFlow2.0和Pytorch发展以及选择

编程风格对比 | 选择

TensorFlow2.0和Pytorch发展以及选择

  • 项目数量对比:
    TensorFlow2.0和Pytorch发展以及选择
    TensorFlow2.0和Pytorch发展以及选择
    TensorFlow2.0和Pytorch发展以及选择
    TensorFlow2.0和Pytorch发展以及选择
    以上可以看出,截止2018年 TensorFlow借助 Google良好的生态圈;然而 Pytorch由于 Facebook的隐私丑闻;
    所以发展的并不理想.
    TensorFlow2.0和Pytorch发展以及选择

开启TensorFlow2.0

所以,以便我们开启学习 TensorFlow2.0需要:
忘掉1.0一些特性,专注于算法 少关心底层实现.
TensorFlow2.0和Pytorch发展以及选择

  • TensorFlow2.0生态库
    通过 function方法,进行了 静态图转化为 动态图.
    TensorFlow2.0和Pytorch发展以及选择
  • 跟进:两者主修其一,学会其一——另外一个 自动就逐渐掌握.(因为相对来说 极其类似)
  • Keras逐渐淡出 —— 因为Google收购了Keras,不可能推出两款产品(这会然用户困扰。)
    • 其中如果有,也使用: tf.keras 进行操作—— tensorflow中 借鉴keras的API进行
      TensorFlow2.0和Pytorch发展以及选择

为什么学习TensorFlow

  • GPU加速 —— 有矩阵并行加速效果
    TensorFlow2.0和Pytorch发展以及选择

  • 自动求导
    TensorFlow2.0和Pytorch发展以及选择

  • 拥有众多神经网络API
    全连接 卷积层 一些列**函数等
    TensorFlow2.0和Pytorch发展以及选择

Pytorch

TensorFlow2.0和Pytorch发展以及选择
16年pytorch的后端(即 c和c++的实现)是基于 troch进行;18年pytorch基于 caffe2进行底层实现.前端API还是torch的模子——人们习惯了这么使用.
TensorFlow2.0和Pytorch发展以及选择
后端自己间接参考theano,
收购后 加上了keras调用.
前端1,0静态图 是自己风格使用,后期2,0才逐渐有了动态图
前者更新时间 要晚于后者。

发展历程

TensorFlow2.0和Pytorch发展以及选择

动态图

TensorFlow2.0和Pytorch发展以及选择
动态图建立 和 代码的一行行运行是同时进行的.

Torch API库多

TensorFlow2.0和Pytorch发展以及选择