Loss_Function_of_Linear_Classifier_and_Optimization
Loss_Function_of_Linear_Classifier_and_Optimization
Multiclass SVM Loss:
Given an example(xi, yi>/sub>) where xi is the image and where yi is the (integer) label, and using the shorthand for the scores vectors: s = f(xi, W), then:
the SVM loss has the form: \(L_i = \sum\limits_{j != y_i} max(0, s_j-s_{y_i}+1)\),
code format:
L_i_vectorized(x, y, W):
scores = W.dot(x)
margins = np.maximun(0, scores - scores[y] + 1)
margins[y] = 0
loss_i = np.sum(margins)
return loss_i
Adding Regularization:
L = \(\frac{1}{N}*\sum\limits_{i = 1}^{N}{\sum\limits_{i != y_i}{max(0, f(x_i; W)_j - f(x_i; W)_{y_i} + 1)}} + \lambda*R(W)\) \((\lambda)\sum\limits_k{\sum\limits_l{W_{k, l}^2}}\)
Benefits in initializing parameters:
x = [1 1 1 1]
W1 = [1 0 0 0]
W2 = [0.25 0.25 0.25 0.25]
Without the regularization item, the dot result will be the same ones, while actually W2 is better than W1 as common sense. If the regularization item is added into it, the result won't be the same, so we can classify them.
Other Regularization Methods: Elastic net(L1+L2), Max norm regularization, Dropout.
Softmax Classifier (Multinomial Logistic Regression):
Loss_Function_of_Linear_Classifier_and_Optimization的更多相关文章
随机推荐
- 数据分析——Numpy/pandas
NumPy NumPy是高性能科学计算和数据分析的基础包.部分功能如下: ndarray, 具有矢量算术运算和复杂广播能力的快速且节省空间的多维数组. 用于对整组数据进行快速运算的标准数学函数(无需编 ...
- CMU数据库(15-445)实验2-B+树索引实现(下+课上笔记)
4. Index_Iterator实现 这里就是需要实现迭代器的一些操作,比如begin.end.isend等等 下面是对于IndexIterator的构造函数 template <typena ...
- 解决Spirng注入时名称下的红色波浪线
解决Spirng注入时名称下的红色波浪线 报错情形: 解决办法: 方案一: 如果可以正常运行,那么可能是类没有交给Spring管理,如下图,我们只需要在对应的接口(或者类上)加上@Component注 ...
- 服务发现 ap cp 强一致性 最终一致性 dns vip ip
为什么基于域名 08 | 服务发现:到底是要CP还是AP? https://time.geekbang.org/column/article/208171 为什么需要服务发现?先举个例子,假如你要给一 ...
- Java 常见关键字总结:final、static、this、super!
final,static,this,super 关键字总结 final 关键字 final关键字,意思是最终的.不可修改的,最见不得变化 ,用来修饰类.方法和变量,具有以下特点: final修饰的类不 ...
- FlightGear 从输出所省略的额外重寻址溢出
2020-12-27 在龙芯Fedora28上编译 FlightGear 2019.1.1 时遇到 从输出所省略的额外重寻址溢出 错误,错误信息如下: [ 98%] Linking CXX execu ...
- loj10008家庭作业
题目描述 老师在开学第一天就把所有作业都布置了,每个作业如果在规定的时间内交上来的话才有学分.每个作业的截止日期和学分可能是不同的.例如如果一个作业学分为10 ,要求在6 天内交,那么要想拿到这 10 ...
- ThinkPHP 5.0.24 反序列化RCE (Windows下EXP)
直接上exp吧,Windows下. <?php namespace think\process\pipes; class Windows { private $files = []; publi ...
- H5Slides幻灯演示系统
H5Slides幻灯演示系统基于HTML5的幻灯片编辑,播放的工具. 通过HTML5的技术,可以在浏览器上进行编辑.传播.控制幻灯片. 选择样板模式 添加新的页面 特点 它是HTML5的! 不需要臃肿 ...
- Spark 将DataFrame所有的列类型改为double
Spark 将DataFrame所有的列类型改为double 1.单列转化方法 2.循环转变 3.通过:_* 1.单列转化方法 import org.apache.spark.sql.types._ ...