Assigment1作业网址:https://cs231n.github.io/assignments2020/assignment1/
课程主页
http://cs231n.stanford.edu/index.html
课件下载
http://cs231n.stanford.edu/syllabus.html
Assigment1要求完成的作业为:
KNN;SVM;softmax分类器;一个简单的两层神经网络的实现
注:PASS为占位语句
KNN
- 训练过程
KNN的训练过程只是简单的记住数据的过程。
时间复杂度为O(n)
Inputs:
- X: A numpy array of shape (num_train, D) containing the training data
consisting of num_train samples each of dimension D.
- y: A numpy array of shape (N,) containing the training labels, where
y[i] is the label for X[i].
#输入的X为N*D的样本:N为样本大小,D为每个样本有D维
#输入的Y为1*N的样本,N为样本大小
- 训练过程
- 计算测试图像和训练集所有图像的L2距离,(其中有是双循环,单循环,无循环三种方法);
双循环:即将训练和测试集都看成一维的
dists[i,j] = np.sqrt(np.sum(np.square