试读部分
目录 Inline Question 1 Inline Question 2 超参数优化 设置验证集 交叉验证 predict_labels函数优化(acc:27.4%->29.4%) Inline Question 3 assignment-1作业地址如下: https://cs231n.github.io/assignments2022/assignment1/ 在导入训练集和测试集的时候遇到了: FileNotFoundError: [Errno 2] No such file or directory: 'cs231n/datasets/cifar-10-batches-py\\data_batch_1' 于是将数据集下到本地,这里我数据集在本地的相对于knn.ipynb的地址:cs231n/datasets/CIFAR10(下载数据可看:传送门) 第一个任务是完成compute_distances_two_loops部分: Compute the distance between each test point in X and each training point in self.X_train using a nested loop over both the training data and the test data. 计算一下欧氏距离就好了,其实就是遍历X_test(500个)中的所有样本,计算每个样本与X_train(5000个)的距离,并把距离保存在dists数组中(dists数组的维度:500, 5000): dists[i, j] = np.sum((X[i] - self.X_train[j])**2)**0.5
一些numpy的文档可看:https://cs231n.github.io/python-numpy-tutorial/#ju……
本文为 VIP 文章,已展示部分内容,开通 VIP 后查看全文
觉得这篇文章有帮助?
点个赞,或赞赏支持作者持续创作