CS231n主要是关于image classification的一些算法以及迁移到其他问题的几个应用。这几节的内容比较基础,正好有时间就过一遍。
Lecture 2 image classification pipeline
compare two images
- L1 (Mahanttan)Distance:
L
=
∑
∣
X
i
j
−
Y
i
j
∣
L = \sum{|X_{ij} - Y_{ij}|}
L=∑∣Xij−Yij∣
- depends on the coordinate
- application: the different features have different meaning, here maybe L1 is better.
- L2 (Euclidean) distance d ( I 1 , I 2 ) = ∑ ( I 1 p − I 2 p ) 2 d(I_1, I_2) = \sqrt{\sum{(I_1^p-I_2^p)^2}} d(I1,I2)=∑(I1p−I2p)2
K-Nearest Neighbors
- training is unnecessary
- distance metrics is essential
- it’s better that the samples in the training data can densely cover the space. It’s obviously hard in high-dimension spaces.
cross validation
- split all the training data and validation data into several folds.
- use every fold as the validation data, the results are average in some ways.
- high cost of computation.
linear classifier
- if we only use a matrix W to classify, the parameters of every category in W actually learn a template which explains the importance of each pixel and usually resembles the average circumstance.
- Here is an interesting demo to have fun, http://vision.stanford.edu/teaching/cs231n-demos/linear-classify/.
Lecture 3 Loss function and optimization
Hinge Loss
- consider the difference between the probability of true label and that of the false ones.
Occam’s Razor
Among the competing hypotheses, the simplest is the best. – William of Ockham
Regularization
- L1 : prefer more zeroes in the parameters in order to decrease the complexity. W1 = [1,0,0,0,0]
- L2 : prefer to spread the influence over all the parameters.(more pixels and parameters are working) W2 = [0.2,0.2,0.2,0.2,0.2]
Histogram of oriented gradient
方向梯度直方图(HOG),通过计算和统计图像局部区域的梯度方向直方图来构成特征,主要应用于图像识别、行人检测。2015年CVPR首次提出了HOG+SVM进行行人检测。
- 主要思想:局部图像的表象和形状呢能够通过梯度的方向密度分布很好的表现出来。
- 主要流程
- 利用gamma校正法标准化输入图像,目的是调整图像的对比度降低阴影和光照变化的影响,抑制噪声干扰。
- 计算每个像素的梯度的大小和方向
- 将图像划分成小cell(比如6*6像素)
- 统计每个cell的梯度直方图:将梯度方向划分为几个bin,然后权重梯度的大小
- 将多个cell组合成block,所有cell的特征拼接起来作为block的特征
- 将图片设置一个步长扫描确定block的个数,拼接所有block的特征作为image的特征