CS231n_1 & 2

回来积极投身CNN的学习和研究中,受到博后哥哥宪标的推荐,毅然决然去学习standford CS231n关于CNN的公开课CNN for Visual Recognition,主要由飞飞姐和Karpathy、Johnson主讲,
Youtube视频
课程主页

第一课 Introduction

首先不出意外地第一节课是Introduction,飞飞对CV的研究发展历史给出了一个比较中肯的conclusion,从生物视觉的起源到Da Vinci的摄影技术以及第一篇CV phd Thesis. 主要提到了计算机视觉围绕主要的问题,有一个宏观意义上的认识。物体是识别、分类、切割、定位等,还能延伸出许多的子问题。

经典工作

这里关键读一下CV历史上影响巨大的几篇文章:
一.AdaBoost Face Detection:使得人脸的识别可以实时应用,主要Contribution:1.Harr特征的边缘提取 2.积分图的快速计算 3.AdaBoost的学习分类器
二.SIFT:Lowe大神经典之作,每个CV人都知道的图片经典特征点,具有shift、rotate、scale不变性:1.构建高斯图像金字塔 2.提取特征点 3.特征描述子的建立
三.金字塔匹配:CVPR06工作,将图片分块成多个空间金字塔,从而结合BoW等技术进行有效的匹配和分类

ImageNet主要关注在CV核心问题,图像识别和分类定位等问题。起初使用的模型一般是提取特征点->建立字典和模型->学习分类算法(SVM)->预测结果;如今DL的火热,使得CNN成为研究CV的主工具。

关于CNN的工作

1.LeCun大神的MNIST文字识别库,文章比较了多种ML方法在库上的表现,当年使用的CNN达到了非常好的效果,但具有训练速度慢、收敛难等问题
2.ImageNet12上,AlexNet这篇经典的CNN文章引爆了潮流,主要使用ReLU、GPU加速、LRN、Data Augument等技术使得CNN避免Overfitting,方便梯度传递,加速训练、解决DL收敛困难的主要问题,在比赛上获得惊人的效果。

课程的Pre-Requisite

  • high proficiency in python和c++
  • Linear Algebra
  • Machine Learning

第二课 Classification

Image Classification

ImageClassification Tutorial
Challenges:Viewpoint Variation, Scale Variation, Deformation, Occlusion, Iluumnation conditions, Background Clutter, Intra-class Variation.(图像识别的经典难点)

Data-Driven Approach: Input->Learning->Evaluation
根据训练样本的学习出来模型,从而对新来的样本进行分类识别的方法

Nearest Neighbor Classifier,具体为KNN: 1.Distance Metric的选择 2.k值的选择(根据Cross Validation,e.g. 5-fold cross-validation),从训练集中切成5份,轮着用一份训练,剩余四份Evaluate,从而调整hyperParameters
k-fold分析图,对于一般性的数据集,K在4-7取得更加的效果,K越大越smooth,expensive也越大

[tips:Evaluate on the test set only a single time, at the very end.确保最后才使用testSets,避免overfit for testSets,保证了模型的generlzation]

Ads: Easy to understand and implement
Draws: Pay computational cost at test time(因此提出了ANN的近似加速,还有FLANN的库)
Pixel-based distances on high-dimensional data can be very unintuitive.(不适用,就像图片平移或者出现Artifacts等情况,但pixel-based distance是不适应人眼的;这里karpathy用了t-SNE对CIFAR-10的图片作了一个分布排列,相似的放在一起,可以看到背景相似但内容不一的东西反而靠在一起了)
t-SNE对CIFAR-10的分布
cons: suit for the low-dimensional data

Summary: 1.Introduce the problem of image classification, image mapping label
2.introduce the NN classifier

  1. Using validation set for tuning the hyperparameters, split training data into two: a training set and a fake test set. Try different hyperparameter values
  2. Once the parameter found, we fixed and use actual test set to evaluation
  3. the NN only get about 40% accuracy on CIFAR-10, while human achieve 94% and CNN achieve already 95%!
  4. the L1 or L2 distances on raw pixel is not adequate since more strongly relative with backgrounds and color distributions rather than semantic content

Practice with kNN:

  1. Preprocessing: Normalize the data in zero mean and unit variance
  2. If the data is high dimensional, using dimensionality reduction technique such as PCA or even Random Projections
  3. Split your traiing data randomly into train/val splits. About 70%~90% of data usually goes to the train split. It depens on how many hyperparameters you have and how much influence you expect them to have. (Cross-validation with the more folds the better, but more expensive)
  4. Train and evaluate kNN on validation data for many choices of k and across different distance types(暴力人为去尝试,加上自己实验的理解)
  5. If kNN running too long, consider using ANN library(FLANN, cost of some accuracy)
  6. Normaly do not use the validation set into the training data, we burned it for unestimated influence. Then evaluate with the test set and report the result as the performance of the kNN models.

Linear Claissification

kNN disadvantages: 1.需要存储training data for comparison
2.与数据库comparison十分耗时

Using a score function and loss function to build a powerful model rather than the kNN
$f(x_i,W,b) = Wx_i+b$

这里主要把W,b的参数学习,x为图片输入,将像素和通道展开成一维超长向量,假设有10类,则b为【10*1】为,得到一个10维的向量,分别表示对应类别的得分。如此一来,新来样本分类只要计算一个矩阵乘法和向量加法就得到结果了,比原先kNN不知道快到哪里去。

思考:这里Linear Classification相当于做了什么,怎么去理解?1.学习了对应类别的一个模板匹配 2.在高维度空间对数据样本做线性分类学习(有点像SVM)
这里将学习得到的Linear Classification再重新可视化之后,得到以下的结果
类别模板可视化

坚持分享,支持原创