添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

本文讲解《Google工程师亲授 Tensorflow2.0-入门到进阶》的第一章,TensorFlow2简介与开发环境的安装
视频地址: https://coding.imooc.com/class/chapter/344.html#Anchor

TensorFlow2简介

TensorFlow2: google的开源软件库;采取数据流图(流程图)、用于数值计算;支持多种平台(GPU、CPU、移动设备);最初用于深度学习,变得越来越通用

数据流图:
数据流图

TensorFlow2的发展史

  1. 2015.11 发布 0.1
  2. 2017.2 发布 1.0
  3. 2019春 发布 2.0 alpha
  4. TensorFlow1.X的主要特性与缺点

    主要特性

    1. XLA————提升训练速度58倍,可以再移动设备运行
    2. 引入更高级的API————tf.layers/tf.metrics/tf.losser/tf.keras
    3. TensorFlow调试器
    4. 支持docker镜像,引入TensorFlow Serving服务
    5. 1.X的架构

      1.X的架构

      1.X的缺点

      1. API混乱
      2. 入口困难,入了门依旧困难
      3. 大批研究人员转向PyTorch
      4. TensorFlow2.X的主要特性与优点

        主要特性

        1. 使用tf.keras和eager mode进行更加简单的模型构建
        2. 鲁棒的跨平台模型部署
        3. 强大的研究实验————keras、自定义训练逻辑
        4. 清除不推荐使用的API和减少重复来简化API
        5. 2.X的架构

          2.X的架构

          2.X简化的模型开发流程

          1. 使用tf.data加载数据
          2. 使用tf.keras构建模型,也可以使用premade estimator来验证模型。使用tensorflow hub进行迁移学习
          3. 使用eager mode进行运行和调试
          4. 使用分发策略来进行分布式训练
          5. 导出到SavedModel
          6. 使用TensorFLow Serve、TensorFlow Lite、TensorFlow JS部署模型
          7. 2.X的优点

            1. easy to use
            2. 高度的灵活性
            3. 真正的可移植性
            4. 产品和科研结合
            5. 自动求微分
            6. 多语言支持
            7. 性能最优化
            8. TensorFlow使用率最高
              实现效果
            9. TensorFlow与PyTorch

              1. 入门时间
                1.X 静态图
                2.X 动态图
                PyTorch  动态图
              2. 图创建和调试
              3. 忘掉TensorFlow1.x吧
              4. PyTorch和TensorFlow2选一主修(二者都要掌握)
              5. Keras逐渐淡出(已被google收购)
              6. 为什么使用TensorFlow

                1. GPU加速
                2. 神经网络API
                3. 深度学习迅猛发展,2.0发布,机遇在手
                4. 灵活掌握使用TensorFlow框架的能力
                5. 掌握相关的机器学习、深度学习的理论知识
                6. 独立开发项目,掌握大厂一线编程经验
                7. 达到初级深度学习算法工程师/研究者的水平
                8. 本地安装Tensorflow2.0

                  1. 安装Anaconda
                  2. 在Anaconda中创建虚拟环境
                    安装 Tensorflow 2.X
                  3. 在Anaconda虚拟环境中安装 Tensorflow 2.X
                    安装 Tensorflow 2.X
                  4. 安装gpu版本的命令

                    1
                    pip install tensorflow-gpu==2.0.0-alpha0

                    安装cpu版本的命令

                    1
                    pip install tensorflow==2.0.0-alpha0
                  5. 测试
                    在Anaconda中启动Notebook,输入如下命令

                    1
                    2
                    import tensorflow as tf
                    print(tf.__version__)

                    FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.

                    1
                    2
                    3
                    4
                    5
                    6
                    7
                    8
                    9
                    10
                    11
                    12
                    D:\Anaconda3\envs\Tersorflow2.x+Python3.6\lib\site-packages\tensorflow\python\framework\dtypes.py:523: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
                    _np_qint8 = np.dtype([("qint8", np.int8, 1)])
                    D:\Anaconda3\envs\Tersorflow2.x+Python3.6\lib\site-packages\tensorflow\python\framework\dtypes.py:524: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
                    _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
                    D:\Anaconda3\envs\Tersorflow2.x+Python3.6\lib\site-packages\tensorflow\python\framework\dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
                    _np_qint16 = np.dtype([("qint16", np.int16, 1)])
                    D:\Anaconda3\envs\Tersorflow2.x+Python3.6\lib\site-packages\tensorflow\python\framework\dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
                    _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
                    D:\Anaconda3\envs\Tersorflow2.x+Python3.6\lib\site-packages\tensorflow\python\framework\dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
                    _np_qint32 = np.dtype([("qint32", np.int32, 1)])
                    D:\Anaconda3\envs\Tersorflow2.x+Python3.6\lib\site-packages\tensorflow\python\framework\dtypes.py:532: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
                    np_resource = np.dtype([("resource", np.ubyte, 1)])

                    这是因为是numpy版本过高,可以使用如下命令将numpy降级:

                    1
                    pip install -U numpy==1.16.0

                    之后再导入tensorflow的时候就不会有这样的警告了。
                    将numpy降级