zoukankan      html  css  js  c++  java
  • 3. 损失函数和优化介绍

    损失函数和优化介绍

    1. Loss function

    A loss function tells how good our current model classifier is.

    1.1 Multiclass SVM loss

    L i = ∑ j ≠ y i m a x ( 0 , s j − s y i + Δ ) L_i = sum_{j eq y_i}max(0, s_j - s_{y_i} + Delta) Li=j=yimax(0,sjsyi+Δ)
    notation: s = f ( x i , W ) , Δ s = f(x_i, W), Delta s=f(xi,W),Δ is safety margin

    1.2 Regularization

    L ( W ) = 1 N ∑ i = 1 N L i ( f ( x i , W ) , y i ) ⏟ D a t a   l o s s + λ R ( W ) ⏟ R e g u l a r i z a t i o n : M o d e l   s h o u l d   b e " s i m p l e " L(W) = underbrace{frac{1}{N} sum^N_{i = 1}L_i(f(x_i, W), y_i)}_{Data:loss} + underbrace{lambda R(W)}_{Regularization: Model : should : be "simple"} L(W)=Dataloss N1i=1NLi(f(xi,W),yi)+Regularization:Modelshouldbe"simple" λR(W)
    在这里插入图片描述

    1.3 Softmax Classifier

    在这里插入图片描述
     这里计算的是Softmax的损失函数,其实和交叉熵损失是一个东西。交叉熵损失也就是下面这个公式,其目的是为了保持模型预测的概率与ground truth是同分布的。交叉熵公式如下:
    J = − ∑ i = 1 K y i l o g ( P i ) J = -sum^K_{i=1}y_i log(P_i) J=i=1Kyilog(Pi)

    2. Optimization

     这里介绍了数值计算梯度下降和公式计算梯度下降。虽然数值计算梯度下降计算很慢,但是这个可以用来做一个参考,来检测我们写的公式计算梯度是否正确。

  • 相关阅读:
    Q739.每日温度
    面试题46. 把数字成字符串
    [990. 等式方程的可满足性]--并查集
    [128. 最长连续序列]
    javaweb实现简单登陆功能
    7.12_python_lx_practise
    7.12_python_lx_day6
    7.12_python_lx_day5
    7.2_python_lx_day4
    7.2_python_lx_day3
  • 原文地址:https://www.cnblogs.com/lsl1229840757/p/14122586.html
Copyright © 2011-2022 走看看