CS231n 2017Spring Lecture3 Loss Function and Optimization总结

来源:互联网 发布:伊藤润二坏小孩 知乎 编辑:程序博客网 时间:2024/06/14 20:56

Abstract

  1. Define a loss function that quantifies our unhappiness with the scores across the training data.
  2. Come up with a way of efficiently finding the parameters that minimize the loss function.(optimization)

1 Loss Function

  • loss的一些想法
    这里写图片描述

1.1 SVM的loss

这里写图片描述
该SVM Loss的一个特点
这里写图片描述
SVM Loss的形式

Li=ijmax(0,sjsyi+1)

* 对例子计算Loss
这里写图片描述
平均Loss
这里写图片描述
这里有一个问题: What if the sum was over all classes?
其实是不会改变的,因为所有的值(j=i时)都+1所以相当于没有加还多做了操作

CODE例子:

这里写图片描述

另外一点需要注意的是:

这里写图片描述
奥卡姆剃刀原理:Among competing hypotheses,the simplest is the best(model选择的一点sense)

1.2 Regularization

这里写图片描述

1.3 SoftMax Classfier Loss

这里写图片描述

  • SoftMax与SVM不一样,它是找到每个分类的概率来进行分类(如公式)

  • 计算Loss
    这里写图片描述

    SVM与SoftMax Loss的对比

    这里写图片描述

  • 前所述过程总结
    这里写图片描述

2 optimization

  1. 首先有一点找F也叫H(就是数据分布下隐含的函数)的方式是Random Search,这种想法完全无法使用,尤其是数据维度高的时候。
  2. Follow the Scope(GD方法)
    这里写图片描述
    但是计算剃度的时候是直接计算的(即analytic gradient)
    但是这种方法的好处是可以验证你的梯度是不是对的在编程的时候
    In practice: Always use analytic gradient, but check implementation with numerical gradient. This is called a gradient check.

    • SGD的例子
      这里写图片描述

Deal With Image Features

  • RGB
    这里写图片描述
    这里写图片描述
    处理特征的一些方法
    这里写图片描述
    这里写图片描述
    这里写图片描述

最终对比ConvNet

这里写图片描述

原创粉丝点击