windows 和 linux 安装 tensorflow

安装

跟往常一样,我们用 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)

猜你喜欢

转载自www.cnblogs.com/fuhang/p/9237009.html