超平面之间的距离

时间:2012-11-12 08:23:46

标签: math image-processing machine-learning classification image-recognition

我正在尝试自学一些机器学习,并且一直在使用MNIST数据库(http://yann.lecun.com/exdb/mnist/)这样做。该网站的作者在'98中写了一篇关于所有不同类型的手写识别技术的论文,可在http://yann.lecun.com/exdb/publis/pdf/lecun-98.pdf获得。

提到的第10种方法是“切线距离分类器”。这个想法是,如果你将每个图像放在一个(NxM)维向量空间中,你可以计算两个图像之间的距离,作为超平面之间的距离,每个超平面是通过取点来给出超平面,并旋转图像,重新缩放图像,翻译图像等。

我无法弄清楚是否填写了遗漏的细节。我知道其中大多数都是线性算子,那么如何使用这个事实来创建超平面呢?一旦我们有超平面,我们如何与其他超平面保持距离?

1 个答案:

答案 0 :(得分:15)

我会给你一些提示。您需要一些图像处理方面的背景知识。有关详细信息,请参阅23

  • 2是切线距离的c实现
  • 3是一篇详细描述切线距离的论文

图像卷积

根据3,您需要做的第一步是平滑图片。下面我们展示3种不同平滑操作的结果(检查3的第4部分)(左列显示结果图像,右列显示原始图像和卷积运算符)。这一步是将离散矢量映射到连续矢量,使其可微分。作者建议使用高斯函数。如果您需要更多关于图像卷积的背景知识,here就是一个例子。

enter image description here

完成此步骤后,您已计算出水平和垂直位移:

enter image description here enter image description here

计算缩放切线

在这里,我向您展示2中实现的切线计算之一 - 缩放切线。从3开始,我们知道转换如下:

enter image description here

/* scaling */
for(k=0;k<height;k++)
  for(j=0;j<width;j++) {
    currentTangent[ind] = ((j+offsetW)*x1[ind] + (k+offsetH)*x2[ind])*factor;
    ind++;
  }

23实施中td.c的开头,我们知道以下定义:

factorW=((double)width*0.5);
offsetW=0.5-factorW;
factorW=1.0/factorW;

factorH=((double)height*0.5);
offsetH=0.5-factorH;
factorH=1.0/factorH;

factor=(factorH<factorW)?factorH:factorW; //min

作者正在使用尺寸为16x16的图像。所以我们知道

factor=factorW=factorH=1/8, 

offsetH=offsetW = 0.5-8 = -7.5

另请注意我们已经计算了

  • x1[ind] =
  • x2[ind] =

所以,我们插入这些常量:

currentTangent[ind] = ((j-7.5)*x1[ind] + (k-7.5)*x2[ind])/8
                    = x1 * (j-7.5)/8 + x2 * (k-7.5)/8.

由于j(也是k)是0到15之间的整数(图像的宽度和高度是16像素),(j-7.5)/8只是一个分数-0.93750.9375

所以我猜(j+offsetW)*factor是每个像素的位移,它与从像素到图像中心的水平距离成比例。同样,您知道垂直位移(k+offsetH)*factor

计算旋转切线

旋转正切定义如下3

enter image description here

/* rotation */
for(k=0;k<height;k++)
  for(j=0;j<width;j++) {
    currentTangent[ind] = ((k+offsetH)*x1[ind] - (j+offsetW)*x2[ind])*factor;
    ind++;
  }

使用之前的结论,我们知道(k+offsetH)*factor对应y。同样,- (j+offsetW)*factor对应-x。所以你知道这正是3中使用的公式。

您可以找到2中实施的3中描述的所有其他切线。我喜欢3中的下图,它清楚地显示了不同转换切线的位移效应。   enter image description here

计算图像之间的切线距离

只需按照tangentDistance函数中的实现:

// determine the tangents of the first image
calculateTangents(imageOne, tangents, numTangents, height, width, choice, background);

// find the orthonormal tangent subspace 
numTangentsRemaining = normalizeTangents(tangents, numTangents, height, width);

// determine the distance to the closest point in the subspace
dist=calculateDistance(imageOne, imageTwo, (const double **) tangents, numTangentsRemaining, height, width);

我认为以上内容足以让您入门,如果遗漏任何内容,请仔细阅读2并查看{{3}}中的相应实施方案。祝你好运!