下载tensorflow
参考文章:
https://www.cnblogs.com/20183544-wangzhengshuai/p/13956698.html
https://tensorflow.juejin.im/install/install_windows.html
1、先查询下tensorflow支持python哪个版本,再查询anaconda对应版本。
查看tenorflow对python版本的要求 :https://blog.csdn.net/qq_46941656/article/details/119775758
tensorflow历史版本:https://pypi.org/project/tensorflow/#history
查找anaconda对应版本:https://docs.anaconda.com/anaconda/packages/oldpkglists/
anaconda历史版本:https://repo.anaconda.com/archive/
2、后续安装步骤:https://www.cnblogs.com/20183544-wangzhengshuai/p/13956698.html
(防止删除)
1)打开安装好的Anaconda中的 Anaconda Prompt
2)然后输入:conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
这两行代码用来改成连接清华镜像的。
3)打开C:\Users\Administrator\.condarc文件:
删除- defaults
4)然后在Anaconda Prompt中输入:conda create -n tensorflow python=3.5(python版本自己定)
5)输入activate tensorflow,切换了,就代表安装成功了。
6)安装的是CPU版本,那么在命令下紧接着输入:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
报错
1)cannot import name ‘OrderedDict‘ from ‘typing‘
把function_type.py
# from typing import Any, Callable, Dict, Mapping, Optional, Sequence, Tuple, OrderedDict
改成
from typing import Any,Callable,Dict, Mapping, Optional, Sequence, Tuple
from typing_extensions import OrderedDict
2)The Session graph is empty. Add operations to the graph before calling run().
import tensorflow as tf
tf.compat.v1.disable_eager_execution() #保证sess.run()能够正常运行
hello = tf.constant('hello,tensorflow')
sess= tf.compat.v1.Session()#版本2.0的函数
print(sess.run(hello))
3)module 'tensorflow' has no attribute 'Session'
import tensorflow.compat.v1 as tf
tf.compat.v1.disable_eager_execution()