2018年8月18日 星期六

CS231n: Image Classification: k-Nearest Neighbor(kNN)

上課位置
https://www.bilibili.com/video/av17204303/?p=4

Syllabus
http://cs231n.stanford.edu/syllabus.html

作業參考
https://github.com/wjbKimberly/cs231n_spring_2017_assignment

1.K-nearest neighbor 

CIFAR-10 標記好的訓練圖庫,有10種物件
L1-distance also called Manhattan distance:兩張圖的(同位置像素相減後取絕對值)再加總,
,跟L2比起來偏向坐標軸,適合在參數具有特殊意義,例如計算員工薪資與年資的關係使用
L2-distance also called Euclidean distance:兩張圖的(同位置像素相減後平方)加總後取絕對值
nearest neighbor 取L1-distance最小的圖當成判斷結果
K-nearest neighbor 取K張L1-distance最小的圖來投票(K為奇數),看符合最多的是哪個圖,當成判斷結果,K越大,分類boundary越平滑
這種特性的K的值稱為hyperparameters因為事先要選好,不一定能被自動學到
The best way is to try them both and see what works better.

分組方式
K=1會overfitting: 絕對不可以
測試集分成2組train,test 用train來訓練,用test的結果來選擇最佳hyperparameters: 絕對不可以
建議測試集分成2組,train,validation,test,用train來訓練,用validation的結果來選擇最佳hyperparameters,最後出報告要使用test的結果,才會反映出真實的結果

沒有留言:

張貼留言