Tensorflow学习 day01

 安装tensorflow

Ubuntu 下  pycharm   安装Tensorflow学习 day01

点击最右边加号, 选择Tensorflow 然后点击install  ok    完成

使用测试代码 检查是否安装成功  定义两个常量(tf.constant)  然后将其相加  要输出相加结果 需要生成一个session来计算

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.Session()
print(sess.run(result))

结果出现错误

/home/sun/PycharmProjects/mechinelearning/venv/bin/python /home/sun/PycharmProjects/mechinelearning/ch2/test.py
2019-02-09 17:59:38.627974: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA

Process finished with exit code 0

当前的CPU可以支持未编译为二进制的指令AVX2    消除此提示   添加两行代码

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

运行结果

Tensorflow学习 day01

 

上一篇:Constant


下一篇:Java 类文件结构