TensorFlow是什么?
谷歌开发的一个深度学习的框架。使用它无需过多关注内部的实现,就可以简单的实现手写数字识别等功能。
安装
tensorflow 官网提供了很多种安装方式,可前往了解,这里使用国内常用的一种安装方式,沙箱模式。
#######沙箱模式?
就是创建一个文件夹,里面有python运行所需的所有程序文件,理论的讲就是独立的运行环境。
pip 安装(已经安装,跳过)
安装tensorflow 和 沙箱 都需要依赖pip。
macbook:~ wany$ sudo easy_install pip
Password:
Searching for pip
Reading https://pypi.python.org/simple/pip/
...
片刻后安装成功
安装沙箱
macbook:~ wany$sudo pip install --upgrade virtualenv //安装沙箱管理器
macbook:~ wany$virtualenv --system-site-packages tensorflow //创建沙箱
macbook:~ wany$cd tensorflow //进入沙箱
macbook: tensorflow wany$source bin/activate //激活沙箱(activate里的代码里好像就是改了一下路径)
macbook: tensorflow wany$sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.1-py2-none-any.whl //安装tensorflow(Google官网下载)
退出沙箱
(tensorflow) macbook: tensorflow wany$deactivate
macbook: tensorflow wany$
开始使用
(tensorflow) macbook:tensorflow faiwong$ python
Python 2.7.10 (default, Jul 30 2016, 19:40:32)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2017-07-19 22:05:52.941576: 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.
2017-07-19 22:05:52.941605: 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.
2017-07-19 22:05:52.941614: 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.
2017-07-19 22:05:52.941622: 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.
>>> print(sess.run(hello))
Hello, TensorFlow!
>>>
关于具体函数的含义,之后更新