Cs20si 1


title: “CS20SI-1” layout: post date: 2017-09-24 20:48 image: /assets/images/markdown.jpg headerImage: false tag:

Welcome to TensorFlow

Why TensorFlow

  1. Python API;
  2. Portability - 可迁移性。 能够适用于单个或多个CPU、GPU、服务器,或者移动设备;
  3. Flexibility - 弹性。 从树莓派、安卓、Windows、iOS、Linux到服务器集群;
  4. Visualization - 可视化。 其中重要的TensorBoard功能。
  5. Checkpoints - 断点。 可用于管理诸多实验。
  6. Auto-differentiation - 自动微分。不再需要手动求微分。
  7. Large community。 丰富的社区讨论等。
  8. 大量已经使用TensorFlow搭建的项目。

Goals - 目标

  1. 理解TensorFlow的计算图方法;
  2. 探索TensorFlow内置函数;
  3. 学习构建并结构化深度学习的项目。

Off-the-shelf model are not the main purpose of TensorFlow.

TensorFlow provides an extensive suite of functions and classes that allow users to define models from scratch.

And this is what we are going to learn.

我们不是要使用TensorFlow中现成的模型,而是要学会从零搭建自己的模型。

Books

相对而言,TensorFlow发展迅速,书很快就会过时,所以要通过 官网跟踪最新。

Two phases with TensorFlow

What is a tensor?

What is a Session?

A Session object encapsulates the environment in which Operations objects are executed, and Tensor objects are evaluated.

Session 封装一个计算环境,其中完成了 操作 的执行,并计算相应的 张量

Why graphs

  1. 节省计算量。 仅运行只跟所求的变量相关的部分计算图。
  2. 将计算分割成小块,每一部分便于进行自动微分。
  3. 方便进行分布式计算,跨多个CPU、GPU或设备等。
  4. 许多常用的机器学习模型已经训练并通过计算图进行可视化。

小结

这一章在自我摸索的情况下,竟然能够正确输出TensorBoard的展示,也算是一个小意外了。

还是从整体性介绍TensorFlow,有谁在用,为什么要用,该如何使用。

该如何使用 最为重要, 我们希望能够充分利用TensorFlow已经定义好的模块,如各种函数和类,但是最核心的模型部分,还是得从头搭建。

并且特别强调 Computational Graph 计算图这个核心问题。

import tensorflow as tf
x = tf.constant(3, name='x')
y = tf.constant(5, name='y')
add_op = tf.add(x, y)
mul_op = tf.multiply(x, y)
useless = tf.multiply(x, add_op)
pow_op = tf.pow(add_op, mul_op)
with tf.Session() as sess:
    print(sess.run(pow_op))
    summary_writer = tf.summary.FileWriter('tmp/testtb', sess.graph)
0

image.png

rss facebook twitter github youtube mail spotify instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora