安装

跟往常一样,我们用 Conda 来安装 TensorFlow。你也许已经有了一个 TensorFlow 环境,但要确保你安装了所有必要的包。

OS X 或 Linux

运行下列命令来配置开发环境

 

conda create -n tensorflow python=3.5
source activate tensorflow
conda install pandas matplotlib jupyter notebook scipy scikit-learn
conda install -c conda-forge tensorflow

 

 

Windows

Windows系统,在你的 console 或者 Anaconda shell 界面,运行

conda create -n tensorflow python=3.5
activate tensorflow
conda install pandas matplotlib jupyter notebook scipy scikit-learn
conda install -c conda-forge tensorflow
 

Hello, world!

在 Python console 下运行下列代码,检测 TensorFlow 是否正确安装。如果安装正确,Console 会打印出 "Hello, world!"。现在还不需要理解这段代码做了什么,你会在下一节学到。

import tensorflow as tf

# Create TensorFlow object called tensor
hello_constant = tf.constant('Hello World!')

with tf.Session() as sess:
    # Run the tf.constant operation in the session
    output = sess.run(hello_constant)
    print(output)

 

posted on 2018-06-28 09:14  未完代码  阅读(499)  评论(0编辑  收藏  举报