1. 简介

百度百科:TensorFlow是谷歌基于DistBelief进行研发的第二代人工智能学习系统,其命名来源于本身的运行原理。Tensor(张量)意味着N维数组,Flow(流)意味着基于数据流图的计算,TensorFlow为张量从图象的一端流动到另一端计算过程。TensorFlow是将复杂的数据结构传输至人工智能神经网中进行分析和处理过程的系统。
TensorFlow可被用于语音识别或图像识别等多项机器深度学习领域,对2011年开发的深度学习基础架构DistBelief进行了各方面的改进,它可在小到一部智能手机、大到数千台数据中心服务器的各种设备上运行。TensorFlow将完全开源,任何人都可以用。

维基百科:TensorFlow is an open source software library for machine learning in various kinds of perceptual and language understanding tasks. It is currently used for both research and production by different teams in dozens of commercial Google products, such as speech recognition, Gmail, Google Photos, and search, many of which had previously used its predecessor DistBelief. TensorFlow was originally developed by the Google Brain team for Google’s research and production purposes and later released under the Apache 2.0 open source license on November 9, 2015。(大概意思就是Tensorflow应用广泛,工业和学术界都在使用,由Google Brain team 研发的,然后给开源出来了。)

从这两个大概的简介中可以看出来,Tensorflow的应用还是十分广泛的,不论是在学术界还是工业界,而且,近几年来视觉顶会的文章也都陆续的放出Tensorflow版本的code。而且,大多数的公司给出的招聘启事中明确表示,熟悉Tensorflow的优先等等问题,都表明了Tensorflow逐渐在深度学习界表现出来的强大的性能(谁让有个好爹呢~~~~)和受欢迎度。所以,简单了解学习一下这个深度框架也是不错的。

2、环境搭建

我的环境是Ubuntu Kylin 14.04 + Python 2.7(还是习惯使用2.7的python)
下面就是安装步骤了:
第一种方法:
①首先你要有一个linux的系统或者Mac系统,因为到目前为止,Tensorflow还是只能在这两个系统上进行配置的,希望以后会有Windows版本吧。
②下载Tensorflow地址,看好对应的版本,有python2和python3,有GPU或者没有GPU的版本等。
③开始安装,使用python pip tensorflow-0.11.0rc0-*.whl安装完成即可。

第二种方法:
①同样你得需要有系统。
②这个相对比较简单,而且不会出错误的。
(1)先安装pip

# Ubuntu/Linux 64-bit
$ sudo apt-get install python-pip python-dev

# Mac OS X
$ sudo easy_install pip
$ sudo easy_install --upgrade six

如果Ubuntu使用这个方式安装pip出错的话,建议去这里下载安装pip,然后继续进行下一步
(2)使用pip安装TensorFlow,各个版本对应的代码我给放出来(其实就是官网拷贝过来的,哈哈~~~)

# Ubuntu/Linux 64-bit, CPU only, Python 2.7
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.11.0rc0-cp27-none-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled, Python 2.7
# Requires CUDA toolkit 7.5 and CuDNN v5. For other versions, see "Install from sources" below.
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.11.0rc0-cp27-none-linux_x86_64.whl

# Mac OS X, CPU only, Python 2.7:
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.11.0rc0-py2-none-any.whl

# Mac OS X, GPU enabled, Python 2.7:
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow-0.11.0rc0-py2-none-any.whl

# Ubuntu/Linux 64-bit, CPU only, Python 3.4
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.11.0rc0-cp34-cp34m-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled, Python 3.4
# Requires CUDA toolkit 7.5 and CuDNN v5. For other versions, see "Install from sources" below.
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.11.0rc0-cp34-cp34m-linux_x86_64.whl

# Ubuntu/Linux 64-bit, CPU only, Python 3.5
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.11.0rc0-cp35-cp35m-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled, Python 3.5
# Requires CUDA toolkit 7.5 and CuDNN v5. For other versions, see "Install from sources" below.
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.11.0rc0-cp35-cp35m-linux_x86_64.whl

# Mac OS X, CPU only, Python 3.4 or 3.5:
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.11.0rc0-py3-none-any.whl

# Mac OS X, GPU enabled, Python 3.4 or 3.5:
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow-0.11.0rc0-py3-none-any.whl

好了,如果到这个时候没有出现什么错误,而且完成的话,那么表示你已经成功安装了Tensorflow框架了。

3、测试

下面我们就进行测试一下,我们的框架是够安装完好,并且能够正常运行呢~~~
我们打开一个终端,输入python,切换到python IDE,输入以下代码:

$ python
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
Hello, TensorFlow!

>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print(sess.run(a + b))
42
>>>

如果你的也是正常输出Hello,TensorFlow!和42说明已经正确安装好了Tensorflow框架。接下来我们就可以继续去学习者框架了。~~~~

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐