TensorFlow安装配置

来源:互联网 发布:全校第一知乎 编辑:程序博客网 时间:2024/06/16 07:03

深度学习的框架,我们熟知的有caffe,torch和convnet。最近,Google又搞了一个TensorFlow,已经开源:http://www.tensorflow.org/。据说,谷歌的深度学习研究人员都在用TensorFlow,未来也将在机器学习产品中继续使用。那么,作为小码农的我需要紧跟时代的步伐啊,探索一下这个新家伙。

本博文分为两个部分,第一个部分介绍TensorFlow的安装,第二部分探索一下TensorFlow的基本使用知识。

一. TensorFlow的安装

个人觉得TensorFlow的安装比前几个框架的安装简单。小码农我的系统是Ubuntu15.04,这里介绍一下Ubuntu下安装TensorFlow的方法,代码如下:

[python] view plain copy
在CODE上查看代码片派生到我的代码片
  1. <span style="font-size:14px;"># For CPU-only version  
  2. $ pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl  
  3.   
  4. # For GPU-enabled version (only install this version if you have the CUDA sdk installed)  
  5. $ pip install https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl</span>  
需要注意的是系统已经安装好python,假如使用的GPU,还需要把GPU的驱动安装好。GPU驱动安装可参考:http://blog.csdn.net/helei001/article/details/46950853

如果你是其他的系统,请参考网页:http://www.tensorflow.org/get_started/os_setup.md

二. TensorFlow的基本使用

TensorFlow的使用与Python的运算库一样,负责与硬件打交道的是session,用来驱动GPU或者CPU。话不多说,上代码:

[python] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <span style="font-size:14px;">import tensorflow as tf  
  2. # The value returned by the constructor represents the output of the Constant op.  
  3. matrix1 = tf.constant([[3.3.]])  
  4.   
  5. # Create another Constant that produces a 2x1 matrix.  
  6. matrix2 = tf.constant([[2.],[2.]])  
  7. product = tf.matmul(matrix1, matrix2)  
  8. sess = tf.Session()  
  9. result = sess.run(product)  
  10. print result  
  11.   
  12. # Close the Session when we're done.  
  13. sess.close()</span>  


参考链接:

http://www.tensorflow.org/get_started


推荐资料:

[1] first-contact-with-tensorflow

[2] http://learningtensorflow.com/       

[3] https://hackerlists.com/tensorflow-resources/   

0 0
原创粉丝点击