安装Tensorflow
参考:知乎,优快云
使用OS为Windows,步骤概括如下:
- 首先安装Anaconda,进入prompt,使用python --version查看python版本
- 使用 conda create --name tensorflow1 python=3.5.2 (后面的数字换成你的python版本)创建环境
- activate tensorflow1 激活环境
- pip install --upgrade --ignore-installed tensorflow 安装tensorflow(cpu版本)
代码测试
参考:Tensorflow中文社区
我们激活刚才的环境,并启动python,输入以下代码
(注意我们使用的是tf2.0,2.0没有Session模块,网上的一些1.0代码不是很适用,需要进行修改)
import tensorflow as tf
tf.compat.v1.disable_eager_execution() # 2.0兼容1.0
hello = tf.constant('Hello, TensorFlow!')
sess = tf.compat.v1.Session() # 1.0的Session
print(sess.run(hello))
如果打印出字符串Hello, TensorFlow!则为环境搭建成功
Debug
还有一些细节问题,等待后续整理