一.安装及配置:
因为安装GPU版本较难,所以在Windows下利用Anaconda安装TensorFlow的CPU版本,具体方式参考https://blog.csdn.net/Pancheng1/article/details/79890532
之后为了编译方便,又安装了Pycharm,下载网址:https://www.jetbrains.com/pycharm/download/#section=windows
下载了Community版,安装及配置网站:https://www.jetbrains.com/help/pycharm/install-and-set-up-pycharm.html.html#windows 这里要注意安装结束后需要设置解释器interpreter:
File->Settings->Project:projectname->project Interpreter. 在create VirtualEnv 选择tensorflow路径下的python.exe(由于安装在Anaconda下,所以路径为: *盘:\Anaconda\envs\tensorflow\python.exe)
设置结束后运行例程:
import tensorflow as tf
a = tf.constant([1.0, 2.0], name="a")
b = tf.constant([2.0, 3.0], name="b")
result = a+b
sess = tf.InteractiveSession()
print(result.eval())
sess.close()
输出: