安装
第一步:安装pip npm install pip
第2步:安装命令 pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl 第3步:测试 导入tensorflow如果不报错就成功 promote:~ apple$ import tensorflow
测试案例:
promote:~ apple$ python
Python
2.7.11 (v2
.7.11:
6d1b6a68f775, Dec
5 2015,
12:
54:
16)
[GCC
4.2.1 (Apple Inc. build
5666) (dot
3)]
on darwin
Type
"help",
"copyright",
"credits" or "license" for more information.
>>> import tensorflow
/Library/Frameworks/Python.framework/Versions/
2.7/lib/python2
.7/site-packages/sklearn/cross_validation.py:
44: DeprecationWarning: This module was deprecated
in version 0.18 in favor
of the model_selection module
into which all
the refactored classes
and functions are moved. Also note
that the interface
of the new CV iterators are different
from that of this module. This module will be removed
in 0.20.
"This module will be removed in 0.20.", DeprecationWarning)
>>> cat hello_tensorflow.py
File
"<stdin>", line
1
cat hello_tensorflow.py
^
SyntaxError: invalid syntax
>>> import tensorflow
as tf
>>> hello = tf.
constant('Hello, TensorFlow!')
>>> meaning = tf.
constant('The Answer
to Life,
the Universe
and Everything
is ')
>>> sess = tf.Session()
>>> msg_op = sess.
run(hello)
>>> mean_op = sess.
run(meaning)
>>> print(msg_op)
Hello, TensorFlow!
>>> print(mean_op)
The Answer
to Life,
the Universe
and Everything
is
>>> a = tf.
constant(
10)
>>> b = tf.
constant(
32)
>>> cal_op = sess.
run(a + b)
>>> print(cal_op)
42
>>> sess.close()
>>>
图解AI
认证博客专家
数据分析
机器学习
深度学习
致力于:机器学习、深度学习、数据分析、算法、架构、C/C++、Rust、HTML5/webApp、Go、Python、Lua...