下载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()
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)