Pycharm測試Tensorflow是否安裝成功
阿新 • • 發佈:2019-02-13
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執行計算。