stanford_CS231n_learning note_Lec_02 Image Classification pipeline

本文介绍了图像分类的基础知识及KNN算法的应用,探讨了L1与L2距离度量方式的选择,以及如何通过线性分类器进行图像分类。

引言

  • 课程配套Python Numpy Tutorial
    http://cs231n.github.io/python-numpy-tutorial/

  • 图像分类时物体检测、图像场景分类等问题的基础,搞懂这个后面的都容易。

  • 图像分类的挑战:视角变动、光线、形变、遮挡、背景杂斑、同类演变
    这里写图片描述

  • 本节课所学知识:能识别出数千类东西,并使用实时技术,在数毫秒内完成识别—KNN

  • CIFAR-10 dataset
    http://www.cs.toronto.edu/~kriz/cifar.html

这里写图片描述

第一个分类器:Nearest Neighbor Classifier

  • 如何比较图片?如何定义距离?
  • L1距离: d1(I1,I2)=P|IP1IP2|
  • 图像做差求和[test image] - [training image]=[image diff] sum [The final value]
  • 缺点:待预测的图片需要与所有训练集图片作差求和运算,预测图像的分类速度取决于训练集的大小,故此需要大量的计算,与实践中的及时性相悖。
  • CNN在训练上花费了大量实践,在实践中却可以很快的解决图像分类问题。
  • KK改进算法 ANN(2010),由L1(Manhattan distance) L2 (Euclidean) distance
  • L2距离: d2(I1,I2)=(Ip1IP2)2
  • KNN:找到与预测图像最相近的k个图像,然后做投票表决,随着N的增大,图像变平滑
  • Question-1:当使用L2距离时的精度如何?
  • Question-2:kNN在训练集上的精度如何?如何呢?
  • Question-3:选取哪个距离最好?
  • Question-4:最好的k值如何确定?

Answers: Very problem-dependent.Must try them all out and see what works best.

  • 测试集是算法泛化程度的代表,训练集上效果好的数据,如果在测试集上效果不好,说泛化能力不行,即训练模型过拟合
  • 将所有数据划分为三部分:训练集+验证集+测试集
  • 确定参数的方法:K-folds Cross Validation
  • 绘制K-Accuracy图像
    这里写图片描述
  • 然而K-NN算法却从未在图像分类中使用
  • 原因有二:测试集上timecost+距离指标不具有启发意义(说人话:分类预测效果不好)

Summary

  • Image Classification: We are given a Training Set of labeled images, asked
    to predict labels on Test Set. Common to report the Accuracy of predictions
    (fraction of correctly predicted images)
  • We introduced the k-Nearest Neighbor Classifier, which predicts the labels
    based on nearest images in the training set
  • We saw that the choice of distance and the value of k are hyperparameters
    that are tuned using a validation set, or through cross-validation if the size
    of the data is small.
  • Once the best set of hyperparameters is chosen, the classifier is evaluated
    once on the test set, and reported as the performance of kNN on that data.

第二个分类器: Linear Classification

  • 神经网络就是搭积木
  • 助理老师的大论文:图像描述
  • 简单介绍:CNN用于视觉识别+RNN用于排序
  • KNN:非参数化 LC:参数化的方法
  • 线性函数 神经网络 卷积神经网络
  • [32x32x3]images=3072 numbers f(x,W) 10 numbers indicating class scores
  • f(x,W)10×1=W10×3072x3072×1(+b)10×1
  • b不是图像的函数,它是独立的权重参数
  • Question-1: what does the linear classifier do, in English?
    所有分数都是一个所有像素点的加权和,实际上式在计算不同空间位置的颜色之和
  • f(xi,W,b)=Wxi+b 将图像带入训练好的f并重新输出图像
    这里写图片描述
  • 想象将图像所构成的3072个点描绘在高维空间;0直线上对对应的类别得分为0。沿梯度箭头方向的得分将会增高

  • 至此我们建立了一个得分函数score function f(xi,W,b)=Wxi+b ,定义得分最高的类别为图像的预测类别
    这里写图片描述

下堂课的内容:

  • Loss function、
    • Quantifying what it means to
      have a “good” W
  • Optimzation
    • start with random W and find a
      W that minimizes the loss
  • ConvNets
    • tweak the functional form of f(调整函数f的形式)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

GuokLiu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值