🍈 一、TensorFlow的介绍
1. TensorFlow 是什么
是一个深度学习库,由 Google 开源,可以对定义在 Tensor(张量)上的函数自动求导。
Tensor(张量)意味着 N 维数组,Flow(流)意味着基于数据流图的计算,TensorFlow即为张量从图的一端流动到另一端。
它的一大亮点是支持异构设备分布式计算,它能够在各个平台上自动运行模型,从电话、单个CPU / GPU到成百上千GPU卡组成的分布式系统。
支持CNN、RNN和LSTM算法,是目前在 Image,NLP 最流行的深度神经网络模型。
2. 为什么需要 TensorFlow 等库
深度学习通常意味着构建具有多层的大规模神经网络。
[En]
Deep learning usually means building large-scale neural networks with many layers.
除了输入X,函数还使用一系列参数,其中包括标量值、向量以及最昂贵的矩阵和高阶张量。
在训练网络之前,有必要定义一个成本函数。公共代价函数包括回归问题的方差和分类中的交叉熵。
[En]
Before training the network, it is necessary to define a cost function. The common cost function includes the variance of the regression problem and the cross entropy in classification.
在训练过程中,需要不断地将多批新的输入输入到网络中,并在推导出所有参数后,替换代价函数,从而更新整个网络模型。
[En]
During the training, it is necessary to continuously put several batches of new inputs into the network, and after deriving all the parameters, replace the cost function, so as to update the whole network model.
在这个过程中有两个主要问题:1.大数或张量相乘数百万次的处理使得整个模型非常昂贵。二.手动推导需要很长时间。
[En]
There are two main problems in this process: 1. The processing of multiplying large numbers or tensors together for millions of times makes the whole model very expensive. two。 Manual derivation takes a long time.
所以 TensorFlow 的对函数自动求导以及分布式计算,可以帮我们节省很多时间来训练模型。
查看python版本
python --version
🍉 二. TensorFlow的安装
1.电脑已安装Anaconda
2.看一下自己有没有NVIDIA的GPU(非常重要!!)
打开任务管理器或设备管理器,查看GPU 0 或GPU 1是否为NVIDIA
必须是NVIDIA的显卡才能装CUDA!其他品牌的GPU不能用来加速,不要装CUDA!
没有NVIDIA的GPU看这里:(安装cpu版本)
(1)升级pip版本
pip -V
遇到问题看着几篇文章
(4条消息) 解决distributed 1.21.8 requires msgpack, which is not installed错误_sunmingyang1987的博客-CSDN博客https://blog.csdn.net/sunmingyang1987/article/details/102972903?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522164709500516780264098173%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=164709500516780264098173&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-1-102972903.article_score_rank&utm_term=distributed+1.21.8+requires+msgpack%2C+which+is+not+installed.&spm=1018.2226.3001.4187 ; (4条消息) python -m pip install –upgrade pip命令出错,无法升级pip_zb_tjw的博客-CSDN博客https://blog.csdn.net/qq_32239767/article/details/104757874?ops_request_misc=&request_id=&biz_id=102&utm_term=python%20-m%20pip%20install%20–upgrad&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-0-104757874.nonecase&spm=1018.2226.3001.4187 ;
python -m pip install --upgrade pip
(2)如果没有NVIDIA的GPU ,执行(这一步是安装t ensorflow ,t ensorflow 是深度学习开发框架):
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow==1.15
如果还报超时错,
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --default-timeout=100 tensorflow==1.15
如果仍然报超时错,
就在凌晨3点~早上7点之间安装
(3)验证一下:Python 环境下(anaconda prompt下键入:python(回车))出现>>>,然后键入import tensorflow,若没有报错,则安装基本正确。
🍊 三,查看TensorFlow的版本以及安装路径
查看TensorFlow的版本以及安装路径
进入到Python环境
import tensorflow as tf
tf.__version__ # 查看版本
tf.__path__ # 查看安装路径
升级到最新:
CPU版本:
pip install --upgrade tensorflow
GPU版本:
pip install --upgrade tensorflow-gpu
tensorflow2.0的安装
pip install --user tensorflow==2.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
卸载已经安装的tensorflow:输入y,卸载即可。
 pip uninstall tensorflow
一定要注意版本像这种错误很可能就是因为版本问题,可以下载新版的tensorflow.
Original: https://blog.csdn.net/zzqingyun/article/details/123449834
Author: 卿云阁
Title: tensorflow的安装(要注意版本哦)
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/496436/
转载文章受原作者版权保护。转载请注明原作者出处!