CS231n课程笔记:Leture2 Image Classification

 Memorize all data and labels

def train(images, label):
    return model

Predict the label of the most similar training image

def predict(mdoel, test_images):
    return test_labels

L1 distance:

L2 distance: 

 

codes for Nearest Neighbor classifier

import numpy as np


class NearestNeighbor:
    def __init__(self):
        pass
    def train(self, X, y):
        self.Xtr = X
        self.ytr = y

    def predict(self, x):
        num_test = X.shape[0]
        Ypred = np.zeros(num_test, dtype = self.ytr.dtype)
        for i in xrange(num_test):
            distances = np.sum(np.abs(self.Xtr - X[i, :]), axis = 1)
            min_index = np.argmin(distances)
            Ypred[i] = self.ytr[min_index]

    return Ypred

Q:with N examples how fast are training and prediction

A: Train O(1) predictO(N)(要和数据集中的每一个去比较)

 

 

 在训练集中选择不同的超参数来训练我们的算法  在验证集上进行评估 在验证集上表现最好的超参数集 

cross validation

KNN的缺点 

Very slow at test time

Distance metrics on pixels are not informative

Curse of dimensionality

所以什么是一个比较好测量图像之间距离的方法

Linear Classification

总结我们对训练数据的知识 and stick all that knowledge into W(PARAMENTERS)

然后在测试的时候 我们不再需要训练数据 只需要这些参数w

如果我们的图像size 是 32*32*3 然后我们把它展开成3072*1的向量 如果我们想要得到10*1的class scores 我们就需要乘以10*3072的参数矩阵 有时候我们也会加上一个10*1 的bias

举例说明

 所以 linear classification 可以看作是 template matching approach 矩阵中的每一行对应图像的某个板块

如果我们用这种方法看待linear classification 我们实际可以获取该权重矩阵的行 并将他们分解回图像 and visualize those templates as images

我们现在可以可视化与cifar-10中十个类别中的每一个相对应的学习权重矩阵中的那些行

 但是线性分类器只能为每一个类学习一个模板

 我们可以把image 看作是高维空间中的一个点 然后线性分类器正在放入这些线性决策边界 来尝试分类

 问题来了

如何选择正确的W 下节讲~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Lyttonkeepgoing

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值