TensorFlow 安装和实践

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!
>>> 

关于具体函数的含义,之后更新

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 网址 下载与安装 你可以使用我们提供的 Pip, Docker, Virtualenv, Anaconda 或 源...
    九七学姐阅读 4,783评论 3 11
  • 1. 介绍 首先让我们来看看TensorFlow! 但是在我们开始之前,我们先来看看Python API中的Ten...
    JasonJe阅读 11,812评论 1 32
  • xx好厉害,有了自己的工作室,听说还办的风声水起,最近整个团队准备自驾游呢。xx在报刊上发表了自己的文章,还有著作...
    花花果阅读 99评论 0 0
  • 我很想和你有很多话说,但是真的不知道说什么,我很想努力成为一个好的女朋友,我静静的等着你的消息,可能你真的失望了吧...
    陌雨沐阅读 302评论 0 0
  • 原来海绵宝宝是个讲爱情的动画,海洋动物和陆地动物,水和空气,死宅和现充…… 就算晒成干海绵也要竖起小拇指,【我不需...
    heim_dn阅读 798评论 0 0