您的位置:首页 > 其它

Pycharm测试Tensorflow是否安装成功

2018-01-02 16:39 423 查看
import tensorflow as tf

#定义两个向量a,b
a = tf.constant([1.0, 2.0], name='a')
b = tf.constant([2.0, 3.0], name='b')
result = a+b
sess = tf.Session() #生成一个会话,通过一个会话session来计算结果
#实现了一个简单的Tensorflow模型
print(sess.run(result))

>>[ 3.  5.]


若出现计算结果,则安装成功。

2018-01-02 16:33:21.854009: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2018-01-02 16:33:21.854024: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2018-01-02 16:33:21.854028: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2018-01-02 16:33:21.854032: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.


若出现这些标红的代码,可暂时忽略不计,不影响TensorFlow运行计算。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: