Note

After we have established the basic objects and methods in TensorFlow, we now want to establish the components that make up TensorFlow algorithms. We start by introducing computational graphs, and then move to loss functions and back propagation. We end with creating a simple classifier and then show an example of evaluating regression and classification algorithms.

下载本章 Jupyter Notebook

计算图

We show how to create an operation on a computational graph and how to visualize it using Tensorboard.

下载本章 Jupyter Notebook


分层嵌套操作

We show how to create multiple operations on a computational graph and how to visualize them using Tensorboard.

下载本章 Jupyter Notebook


多层操作

Here we extend the usage of the computational graph to create multiple layers and show how they appear in Tensorboard.

下载本章 Jupyter Notebook


载入损失函数

In order to train a model, we must be able to evaluate how well it is doing. This is given by loss functions. We plot various loss functions and talk about the benefits and limitations of some.

下载本章 Jupyter Notebook


载入反向传播

Here we show how to use loss functions to iterate through data and back propagate errors for regression and classification.

下载本章 Jupyter Notebook


随机和批量训练

TensorFlow makes it easy to use both batch and stochastic training. We show how to implement both and talk about the benefits and limitations of each.

下载本章 Jupyter Notebook


结合训练

We now combine everything together that we have learned and create a simple classifier.

下载本章 Jupyter Notebook


模型评估

Any model is only as good as it’s evaluation. Here we show two examples of (1) evaluating a regression algorithm and (2) a classification algorithm.

下载本章 Jupyter Notebook

本章学习模块

tensorflow.zeros

Creates a tensor with all elements set to zero.

This operation returns a tensor of type dtype with shape shape and all elements set to zero.

>>> tf.zeros([3, 4], tf.int32)
<tf.Tensor: shape=(3, 4), dtype=int32, numpy=
array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]], dtype=int32)>
param shape

A list of integers, a tuple of integers, or a 1-D Tensor of type int32.

param dtype

The DType of an element in the resulting Tensor.

param name

Optional string. A name for the operation.

returns

A Tensor with all elements set to zero.


tensorflow.ones

Creates a tensor with all elements set to one (1).

See also tf.ones_like.

This operation returns a tensor of type dtype with shape shape and all elements set to one.

>>> tf.ones([3, 4], tf.int32)
<tf.Tensor: shape=(3, 4), dtype=int32, numpy=
array([[1, 1, 1, 1],
       [1, 1, 1, 1],
       [1, 1, 1, 1]], dtype=int32)>
param shape

A list of integers, a tuple of integers, or a 1-D Tensor of type int32.

param dtype

Optional DType of an element in the resulting Tensor. Default is tf.float32.

param name

Optional string. A name for the operation.

returns

A Tensor with all elements set to one (1).