您的位置:首页 > 编程语言 > Python开发

VS2017+python3.6+Tensorflow环境搭建

2017-09-10 21:58 274 查看
第一步:

安装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才可以,后期送上解决教程)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息