学习效率最高的三个地方:高铁,卫生间。这是高铁上3个小时的思考,记录一下。
深度学习
,这个名字充满神秘感,其实它的本质很好理解,它是一个数学工具,用来拟合某一个函数,这个函数具有很大的VC维,可以对某一个数据集进行很好的分类,同时它又不过拟合,因此可以对其他数据集进行分类预测。
其他的概念都很好理解,VC维
是什么?
数学定义我也看不懂,用大白话来说就是:
H的VC维表示为VC(H) ,指能够被H分散的最大集合的大小。若H能分散任意大小的集合,那么VC(H)为无穷大。
这里需要理解的是,最大集合的大小
,我们以二维线性分类器举例说明为什么其VC维是3,而不能分散4个样本的集合
这个最简单的场景来讨论。
import matplotlib.pyplot as plt
import numpy as np
dots_x = [1, 2]
dots_y = [2, 1]
cross_x = [1]
cross_y = [1]
plt.xlim(0.0, 4)
plt.ylim(0.0, 4)
plt.plot(dots_x, dots_y, 'o')
plt.plot(cross_x, cross_y, 'x')
x = [0, 2, 2.5]
y = [2.5, 0.5, 0]
plt.plot(x, y)
[<matplotlib.lines.Line2D at 0x175fd7dcda0>]

dots_x = [1, 1]
dots_y = [1, 2]
cross_x = [2]
cross_y = [1]
plt.xlim(0.0, 4)
plt.ylim(0.0, 4)
plt.plot(dots_x, dots_y, 'o')
plt.plot(cross_x, cross_y, 'x')
x = [1.5, 1.5, 1.5]
y = [0, 2, 4]
plt.plot(x, y)
[<matplotlib.lines.Line2D at 0x175fd704cc0>]

dots_x = [1, 2]
dots_y = [1, 1]
cross_x = [1]
cross_y = [2]
plt.xlim(0.0, 4)
plt.ylim(0.0, 4)
plt.plot(dots_x, dots_y, 'o')
plt.plot(cross_x, cross_y, 'x')
x = [0, 2, 4]
y = [1.5, 1.5, 1.5]
plt.plot(x, y)
[<matplotlib.lines.Line2D at 0x175fd631a90>]

dots_x = [1, 1, 2]
dots_y = [1, 2, 1]
plt.xlim(0.0, 4)
plt.ylim(0.0, 4)
plt.plot(dots_x, dots_y, 'o')
x = [2.5, 2.5, 2.5]
y = [0, 2, 4]
plt.plot(x, y)
[<matplotlib.lines.Line2D at 0x175fc299240>]

虽然存在着下面的分布,导致无法使用单一线性函数对3个数据点进行分类,但是并不影响单一线性函数能够分类的最大集合的大小是3。
dots_x = [0.5, 1.5]
dots_y = [1, 3]
cross_x = [1]
cross_y = [2]
plt.xlim(0.0, 4)
plt.ylim(0.0, 4)
plt.plot(dots_x, dots_y, 'o')
plt.plot(cross_x, cross_y, 'x')
[<matplotlib.lines.Line2D at 0x175fc4fd908>]

相对的,你可以想象一下,对于任意的4个数据点,无法构造出任何一种分布,使得单一线性函数可以对其进行分类。所以单一线性函数的VC维 < 4。
dots_x = [1, 2]
dots_y = [1, 2]
cross_x = [2, 1]
cross_y = [1, 2]
plt.xlim(0.0, 4)
plt.ylim(0.0, 4)
plt.plot(dots_x, dots_y, 'o')
plt.plot(cross_x, cross_y, 'x')
[<matplotlib.lines.Line2D at 0x175fd84cac8>]

而深度学习训练出来的函数,它理论上的VC维是无穷大的,所以它甚至可以对下面的数据集进行分类。
dots_x = np.random.uniform(0, 100, size=100)
dots_y = np.random.uniform(0, 100, size=100)
cross_x = np.random.uniform(0, 100, size=100)
cross_y = np.random.uniform(0, 100, size=100)
plt.xlim(0.0, 105)
plt.ylim(0.0, 105)
plt.plot(dots_x, dots_y, 'o')
plt.plot(cross_x, cross_y, 'x')
[<matplotlib.lines.Line2D at 0x175fda6ed30>]

这就是深度学习在数学上的定义。
网友评论