注解

This chapter shows how to implement various SVM methods with TensorFlow. We first create a linear SVM and also show how it can be used for regression. We then introduce kernels (RBF Gaussian kernel) and show how to use it to split up non-linear data. We finish with a multi-dimensional implementation of non-linear SVMs to work with multiple classes.

引言

We introduce the concept of SVMs and how we will go about implementing them in the TensorFlow framework.


线性支持向量机

We create a linear SVM to separate I. setosa based on sepal length and pedal width in the Iris data set.

下载本章 Jupyter Notebook


回归线性回归

The heart of SVMs is separating classes with a line. We change tweek the algorithm slightly to perform SVM regression.

下载本章 Jupyter Notebook


TensorFlow中的核

In order to extend SVMs into non-linear data, we explain and show how to implement different kernels in TensorFlow.

下载本章 Jupyter Notebook


非线性支持向量机

We use the Gaussian kernel (RBF) to separate non-linear classes.

下载本章 Jupyter Notebook


多类支持向量机

SVMs are inherently binary predictors. We show how to extend them in a one-vs-all strategy in TensorFlow.

下载本章 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).