VS2017+python3.6+Tensorflow环境搭建

来源:互联网 发布:淘宝德国啤酒杀人酒 编辑:程序博客网 时间:2024/06/08 09:00

第一步:

安装VS2017(参考Opencv那一篇博客),勾选Python选项

第二步:

配置环境变量


第三步:

用管理员打开Power shell

输入:pip3 install --upgrade tensorflow

第四步:

验证是否成功

新建python程序

输入代码:

#coding:utf-8 
import tensorflow as tf
w1 = tf.Variable(tf.random_normal([2,3],stddev=1,seed=1))
w2 = tf.Variable(tf.random_normal([3,1],stddev=1,seed=1))
x = tf.constant([[0.7,0.9]])
a = tf.matmul(x,w1)
y = tf.matmul(a,w2)
sess = tf.Session()
init_op = tf.initialize_all_variables()
sess.run(init_op)
print(sess.run(y))
sess.close()

运行结果:


(其中的提示是因为没有正对CPU进行优化,需要编译tensorflow才可以,后期送上解决教程)

原创粉丝点击