一、深度学习与机器学习的区别
1、特征提取方面
机器学习:人工特征提取 + 分类算法
深度学习:没有人工特征提取,直接将特征值传进去
(1)机器学习的特征工程步骤是要靠手工完成的,而且需要大量领域专业知识
(2)深度学习通常由多个层组成,它们通常将更简单的模型组合在一起,将数据从一层传递到另一层来构建更复杂的模型。通过训练大量数据自动得出模型,不需要人工特征提取环节
(3)深度学习算法试图从数据中学习高级功能,这是深度学习的一个非常独特的部分。因此,减少了为每个问题开发新特征提取器的任务。适合用在难提取特征的图像、语音、自然语言处理领域
2、数据量和计算性能要求
机器学习需要的执行时间远少于深度学习,深度学习参数往往很庞大,需要通过大量数据的多次优化来训练参数
(1)深度学习需要大量的训练数据集
(2)训练深度神经网络需要大量的算力
(3)可能需要数天、甚至数周的时间,才能使用数百万张图像的数据集训练出一个深度网络
所以深度学习通常:
需要强大的GPU服务器来进行计算
全面管理的分布式训练与预测服务
3、算法代表
(1)机器学习
朴素贝叶斯、决策树等
(2)深度学习
神经网络
二、深度学习的应用场景
1、图像识别
(1)物体识别
(2)场景识别
(3)车型识别
(4)人脸检测跟踪
(5)人脸关键点定位
(6)人脸身份认证
2、自然语言处理技术
(1)机器翻译
(2)文本识别
(3)聊天对话
3、语音技术
(1)语音识别
三、深度学习框架介绍
1、常见深度学习框架对比
这是一张2015-2016年的图表,2015年11月谷歌将TensorFlow开源,那时候国内开始卷java好像[笑哭][笑哭][笑哭]
说明:
(1)最常用的框架当属TensorFlow和Pytorch,而Caffe和Caffe2次之
(2)PyTorch和Torch更适用于学术研究(research);TensorFlow、Caffe、Caffe2更适用于工业界的生产环境部署(industrial production)
(3)Caffe适用于处理静态图像(static graph);Torch和PyTorch更适用于动态图像(dynamic graph);TensorFlow在两种情况下都很实用
(4)TensorFlow和Caffe2可在移动端使用
2、TensorFlow的特点
官网:https://tensorflow.google.cn/?hl=zh-cn
(1)高度灵活
它不仅可以用来做神经网络算法研究,也可以用来做普通的机器学习算法,甚至是只要把计算表示成数据流图,都可以用TensorFlow
(2)语言多样性
TensorFlow使用C++实现,然后用Python封装
(3)设备支持
TensorFlow可以运行在各种硬件上,同时根据计算的需要,合理将运算分配到相应的设备,比如卷积就分配到GPU上,也允许在CPU和GPU上的计算分布
(4)Tensorboard可视化
因为深度学习训练出来的模型,参数非常非常多,网络层数也非常非常的多,可视化可以帮助你展示
3、TensorFlow的安装
(1)CPU版本
pip install -U tensorflowCollecting tensorflowDownloading tensorflow-2.6.2-cp36-cp36m-manylinux2010_x86_64.whl (458.3 MB)|████████████████████████████████| 458.3 MB 16 kB/s
Collecting astunparse~=1.6.3Downloading astunparse-1.6.3-py2.py3-none-any.whl (12 kB)
Collecting h5py~=3.1.0Downloading h5py-3.1.0-cp36-cp36m-manylinux1_x86_64.whl (4.0 MB)|████████████████████████████████| 4.0 MB 35.6 MB/s
Collecting tensorboard<2.7,>=2.6.0Downloading tensorboard-2.6.0-py3-none-any.whl (5.6 MB)|████████████████████████████████| 5.6 MB 51.5 MB/s
Collecting grpcio<2.0,>=1.37.0Downloading grpcio-1.48.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.6 MB)|████████████████████████████████| 4.6 MB 47.3 MB/s
Collecting flatbuffers~=1.12.0Downloading flatbuffers-1.12-py2.py3-none-any.whl (15 kB)
Collecting opt-einsum~=3.3.0Downloading opt_einsum-3.3.0-py3-none-any.whl (65 kB)|████████████████████████████████| 65 kB 9.6 MB/s
Collecting clang~=5.0Downloading clang-5.0.tar.gz (30 kB)Preparing metadata (setup.py) ... done
Collecting six~=1.15.0Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting typing-extensions~=3.7.4Downloading typing_extensions-3.7.4.3-py3-none-any.whl (22 kB)
Collecting protobuf>=3.9.2Downloading protobuf-3.19.6-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB)|████████████████████████████████| 1.1 MB 47.2 MB/s
Collecting gast==0.4.0Downloading gast-0.4.0-py3-none-any.whl (9.8 kB)
Requirement already satisfied: numpy~=1.19.2 in /usr/local/lib64/python3.6/site-packages (from tensorflow) (1.19.5)
Requirement already satisfied: wheel~=0.35 in /usr/local/lib/python3.6/site-packages (from tensorflow) (0.37.1)
Collecting google-pasta~=0.2Downloading google_pasta-0.2.0-py3-none-any.whl (57 kB)|████████████████████████████████| 57 kB 11.0 MB/s
Collecting wrapt~=1.12.1Downloading wrapt-1.12.1.tar.gz (27 kB)Preparing metadata (setup.py) ... done
Collecting termcolor~=1.1.0Downloading termcolor-1.1.0.tar.gz (3.9 kB)Preparing metadata (setup.py) ... done
Collecting tensorflow-estimator<2.7,>=2.6.0Downloading tensorflow_estimator-2.6.0-py2.py3-none-any.whl (462 kB)|████████████████████████████████| 462 kB 54.2 MB/s
Collecting absl-py~=0.10Downloading absl_py-0.15.0-py3-none-any.whl (132 kB)|████████████████████████████████| 132 kB 61.0 MB/s
Collecting keras<2.7,>=2.6.0Downloading keras-2.6.0-py2.py3-none-any.whl (1.3 MB)|████████████████████████████████| 1.3 MB 55.6 MB/s
Collecting keras-preprocessing~=1.1.2Downloading Keras_Preprocessing-1.1.2-py2.py3-none-any.whl (42 kB)|████████████████████████████████| 42 kB 3.0 MB/s
Collecting cached-propertyDownloading cached_property-1.5.2-py2.py3-none-any.whl (7.6 kB)
Requirement already satisfied: setuptools>=41.0.0 in /usr/local/lib/python3.6/site-packages (from tensorboard<2.7,>=2.6.0->tensorflow) (59.6.0)
Collecting werkzeug>=0.11.15Downloading Werkzeug-2.0.3-py3-none-any.whl (289 kB)|████████████████████████████████| 289 kB 45.9 MB/s
Collecting markdown>=2.6.8Downloading Markdown-3.3.7-py3-none-any.whl (97 kB)|████████████████████████████████| 97 kB 15.3 MB/s
Collecting google-auth-oauthlib<0.5,>=0.4.1Downloading google_auth_oauthlib-0.4.6-py2.py3-none-any.whl (18 kB)
Collecting google-auth<2,>=1.6.3Downloading google_auth-1.35.0-py2.py3-none-any.whl (152 kB)|████████████████████████████████| 152 kB 54.5 MB/s
Collecting requests<3,>=2.21.0Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB)|████████████████████████████████| 63 kB 4.3 MB/s
Collecting tensorboard-data-server<0.7.0,>=0.6.0Downloading tensorboard_data_server-0.6.1-py3-none-manylinux2010_x86_64.whl (4.9 MB)|████████████████████████████████| 4.9 MB 49.6 MB/s
Collecting tensorboard-plugin-wit>=1.6.0Downloading tensorboard_plugin_wit-1.8.1-py3-none-any.whl (781 kB)|████████████████████████████████| 781 kB 35.3 MB/s
Collecting rsa<5,>=3.1.4Downloading rsa-4.9-py3-none-any.whl (34 kB)
Collecting cachetools<5.0,>=2.0.0Downloading cachetools-4.2.4-py3-none-any.whl (10 kB)
Collecting pyasn1-modules>=0.2.1Downloading pyasn1_modules-0.3.0-py2.py3-none-any.whl (181 kB)|████████████████████████████████| 181 kB 56.0 MB/s
Collecting requests-oauthlib>=0.7.0Downloading requests_oauthlib-1.3.1-py2.py3-none-any.whl (23 kB)
Requirement already satisfied: importlib-metadata>=4.4 in /usr/local/lib/python3.6/site-packages (from markdown>=2.6.8->tensorboard<2.7,>=2.6.0->tensorflow) (4.8.3)
Collecting urllib3<1.27,>=1.21.1Downloading urllib3-1.26.18-py2.py3-none-any.whl (143 kB)|████████████████████████████████| 143 kB 53.4 MB/s
Collecting certifi>=2017.4.17Downloading certifi-2024.2.2-py3-none-any.whl (163 kB)|████████████████████████████████| 163 kB 56.2 MB/s
Collecting idna<4,>=2.5Downloading idna-3.6-py3-none-any.whl (61 kB)|████████████████████████████████| 61 kB 343 kB/s
Collecting charset-normalizer~=2.0.0Downloading charset_normalizer-2.0.12-py3-none-any.whl (39 kB)
Requirement already satisfied: dataclasses in /usr/local/lib/python3.6/site-packages (from werkzeug>=0.11.15->tensorboard<2.7,>=2.6.0->tensorflow) (0.8)
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/site-packages (from importlib-metadata>=4.4->markdown>=2.6.8->tensorboard<2.7,>=2.6.0->tensorflow) (3.6.0)
Collecting pyasn1<0.6.0,>=0.4.6Downloading pyasn1-0.5.1-py2.py3-none-any.whl (84 kB)|████████████████████████████████| 84 kB 8.1 MB/s
Collecting oauthlib>=3.0.0Downloading oauthlib-3.2.2-py3-none-any.whl (151 kB)|████████████████████████████████| 151 kB 41.8 MB/s
Building wheels for collected packages: clang, termcolor, wraptBuilding wheel for clang (setup.py) ... doneCreated wheel for clang: filename=clang-5.0-py3-none-any.whl size=30694 sha256=4b478abb7303e2ab6ceae5dd321630fe487cdbb7229b1c9109dbbda97b6f6de0Stored in directory: /root/.cache/pip/wheels/22/4c/94/0583f60c9c5b6024ed64f290cb2d43b06bb4f75577dc3c93a7Building wheel for termcolor (setup.py) ... doneCreated wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=4848 sha256=85b28ee5cc23acde89b4124855db5fec4d3b5bc9f09d22853e2a5d32f869232fStored in directory: /root/.cache/pip/wheels/93/2a/eb/e58dbcbc963549ee4f065ff80a59f274cc7210b6eab962acdcBuilding wheel for wrapt (setup.py) ... doneCreated wheel for wrapt: filename=wrapt-1.12.1-cp36-cp36m-linux_x86_64.whl size=64570 sha256=5313bb733d9d37abf00e4ce2533656facec5e4518e11aaafb7dbb3171cd1bcaaStored in directory: /root/.cache/pip/wheels/32/42/7f/23cae9ff6ef66798d00dc5d659088e57dbba01566f6c60db63
Successfully built clang termcolor wrapt
Installing collected packages: urllib3, pyasn1, idna, charset-normalizer, certifi, typing-extensions, six, rsa, requests, pyasn1-modules, oauthlib, cachetools, requests-oauthlib, google-auth, werkzeug, tensorboard-plugin-wit, tensorboard-data-server, protobuf, markdown, grpcio, google-auth-oauthlib, cached-property, absl-py, wrapt, termcolor, tensorflow-estimator, tensorboard, opt-einsum, keras-preprocessing, keras, h5py, google-pasta, gast, flatbuffers, clang, astunparse, tensorflowAttempting uninstall: typing-extensionsFound existing installation: typing-extensions 4.1.1Uninstalling typing-extensions-4.1.1:Successfully uninstalled typing-extensions-4.1.1Attempting uninstall: sixFound existing installation: six 1.16.0Uninstalling six-1.16.0:Successfully uninstalled six-1.16.0
Successfully installed absl-py-0.15.0 astunparse-1.6.3 cached-property-1.5.2 cachetools-4.2.4 certifi-2024.2.2 charset-normalizer-2.0.12 clang-5.0 flatbuffers-1.12 gast-0.4.0 google-auth-1.35.0 google-auth-oauthlib-0.4.6 google-pasta-0.2.0 grpcio-1.48.2 h5py-3.1.0 idna-3.6 keras-2.6.0 keras-preprocessing-1.1.2 markdown-3.3.7 oauthlib-3.2.2 opt-einsum-3.3.0 protobuf-3.19.6 pyasn1-0.5.1 pyasn1-modules-0.3.0 requests-2.27.1 requests-oauthlib-1.3.1 rsa-4.9 six-1.15.0 tensorboard-2.6.0 tensorboard-data-server-0.6.1 tensorboard-plugin-wit-1.8.1 tensorflow-2.6.2 tensorflow-estimator-2.6.0 termcolor-1.1.0 typing-extensions-3.7.4.3 urllib3-1.26.18 werkzeug-2.0.3 wrapt-1.12.1
(2)GPU版本
注:GPU版本适用于带有CUDA核心的NV显卡,英特尔的核显,AMD的显卡不行
(3)CPU版本和GPU版本对比
CPU:核心的数量更少,但是每一个核心的速度更快,性能更强,更适用于处理连续性(sequential)任务
GPU:核心的数量更多,但是每一个核心的处理速度较慢,更适合于并行(parallel)任务