[ICNN 1993] Optimal brain surgeon and general network pruning

news/2024/10/23 7:31:17/

Contents

Introduction

  • 作者提出 Optimal brain damage (OBD) 的改进 Optimal brain surgeon (OBS) 用于模型剪枝

Method

Optimal brain surgeon (OBS)

  • 类似于 Optimal brain damage (OBD),OBS 也 δ E \delta E δE 用泰勒公式展开
    在这里插入图片描述其中, E E E 为损失函数, w w w 为权重向量, H = ∂ 2 E / ∂ w 2 H=\partial^2E/\partial w^2 H=2E/w2 为 Hessian matrix. 类似于 OBD,为了简化上式,作者假设剪枝前模型权重已位于局部最小点从而省略第一项,假设目标函数近似二次函数从而省略第三项,但需要注意的是,不同于 OBD,这里作者并没有使用 “diagonal” approximation,不假设 H H H 为对角矩阵。这样上式就简化为了
    δ E = 1 2 δ w T ⋅ H ⋅ δ w \delta E=\frac{1}{2}\delta w^T\cdot H\cdot \delta w δE=21δwTHδw
  • 在剪枝过程中,对 w q w_q wq 进行剪枝可以表示为 δ w q + w q = 0 \delta w_q+w_q=0 δwq+wq=0,也可以被表示为
    在这里插入图片描述其中, e q e_q eq 为对应 (scalar) weight w q w_q wq 的单位向量。这样剪枝过程可以被表示为求解如下最优化问题
    在这里插入图片描述求解完成后对 w q w_q wq 进行剪枝即可。为了解上式,可以将其写为拉格朗日展式:
    在这里插入图片描述对其求解可以得到 optimal weight changeresulting change in error 分别为
    在这里插入图片描述
  • Optimal Brain Surgeon procedure. 可以看到,OBS 其实是 OBD 的推广,首先 OBS 不假设 H H H 为对角矩阵;其次在进行剪枝后,OBS 会对所有权重参数进行更新,从而对被剪枝的权重进行补偿,使得损失函数在剪枝后尽可能更小
    在这里插入图片描述在这里插入图片描述

Computing the inverse Hessian

  • 现在唯一的问题就是如何高效计算 H − 1 H^{-1} H1,为此作者提出了 outer-product approximation

计算 H H H

  • 现在考虑非线性网络 F F F
    在这里插入图片描述其中, i n \mathbf{in} in 为输入向量, w \mathbf{w} w 为权重, o \mathbf{o} o 为输出向量。训练集上的均方误差可以表示为
    在这里插入图片描述由此可以计算出 w \mathbf{w} w一阶导
    在这里插入图片描述注意上式中的 ∂ F ( w , i n [ k ] ) ∂ w ( t [ k ] − o [ k ] ) \frac{\partial F(\mathbf w,\mathbf {in}^{[k]})}{\partial \mathbf w}(\mathbf t^{[k]}-\mathbf o^{[k]}) wF(w,in[k])(t[k]o[k]) 为向量逐元素乘。进一步可以推出二阶导 / Hessian
    在这里插入图片描述
  • 下面对上式做进一步简化。假设模型已经达到了误差局部极小点,此时可以 t [ k ] − o [ k ] ≈ 0 \mathbf t^{[k]}-\mathbf o^{[k]}\approx\mathbf 0 t[k]o[k]0 可以忽略 (Even late in pruning, when this error is not small for a single pattern, this approximation can be justified, explained in the nest section),由此可得
    在这里插入图片描述
    在这里插入图片描述则得到了 Hessian matrix 的 outer-product approximation
    在这里插入图片描述其中, P P P 为训练集样本数, X [ k ] \mathbf X^{[k]} X[k] 为第 k k k 个样本的 n n n-dimensional data vector of derivatives. 假如网络有多个输出,则 X \mathbf X X
    在这里插入图片描述Hessian matrix 为
    在这里插入图片描述
  • 考虑模型只有单一输出的情况,我们可以遍历训练集,迭代地计算 H H H
    在这里插入图片描述其中, H 0 = α I H_0=\alpha I H0=αI H P = H H_P=H HP=H

计算 H − 1 H^{-1} H1

  • 根据 Woodbury identity 可知,
    在这里插入图片描述将其代入 H H H 的迭代式可知,
    在这里插入图片描述其中, H 0 − 1 = α − 1 I H^{-1}_0=\alpha^{-1}I H01=α1I H P − 1 = H − 1 H_P^{-1}=H^{-1} HP1=H1 α \alpha α ( 1 0 − 8 ≤ α ≤ 1 0 − 4 10^{-8}\leq\alpha\leq 10^{-4} 108α104) 为 a small constant needed to make H 0 − 1 H^{-1}_0 H01 meaningful.
  • 实际上,上述迭代求解出的 H P − 1 H_P^{-1} HP1 ( H + α I ) (H+\alpha I) (H+αI) 的逆。原来的拉格朗日展式为
    在这里插入图片描述如果将 H H H 替换为 ( H + α I ) (H+\alpha I) (H+αI),则相当于是加上了正则项 α ∥ δ w ∥ 2 \alpha\|\delta\mathbf w\|^2 αδw2,可以避免剪枝后权重向量值更新过大,同时也保证了将 δ E \delta E δE 用泰勒公式展开时忽略高次项的合理性

The ( t − o ) → 0 (\mathbf t-\mathbf o)\rightarrow 0 (to)0 Approximation

  • Computational view. H \mathbf H H 在剪枝前通常是不可逆的, ( t − o ) → 0 (\mathbf t-\mathbf o)\rightarrow 0 (to)0 的近似可以保证 H − 1 \mathbf H^{-1} H1 的计算是有良好定义的. In Statistics the approximation is the basis of Fisher’s method of scoring and its goal is to replace tlie true Hessian with its expected value and hence guarantee that H \mathbf H H is positive definite.
  • Functional justifications. (这里没看太明白) Consider a high capacity network trained to small training error. We can consider the network structure as involving both signal and noise. As we prune, we hope to eliminate those weights that lead to “overfitting.” i.e., learning the noise. If our pruning method did not employ the ( t − o ) → 0 (\mathbf t-\mathbf o)\rightarrow 0 (to)0 approximation, every pruning step (Eqs. 9 and 8) would inject the noise back into the system, by penalizing for noise terms. A different way to think of the approximation is the following. After some pruning by OBS we have
    reached a new weight vector that is a local minimum of the error. Even if this error is not negligible, we want to stay as close to that value of the error as we can. Thus we imagine a new effective teaching signal t ∗ \mathbf t^* t, that would keep the network near this new error minimum. It is then ( t ∗ − o ) (\mathbf t^*-\mathbf o) (to) that we in effect set to zero when using Eq. 11 instead of Eq. 10.

References

  • Hassibi, Babak, David G. Stork, and Gregory J. Wolff. “Optimal brain surgeon and general network pruning.” IEEE international conference on neural networks. IEEE, 1993.

http://www.ppmy.cn/news/328312.html

相关文章

中控考勤机忘记密码处理

1、要进入考勤机,首先要知道考勤机的超级管理号码。考勤机的超级号码是8888.可以直接在考勤机屏幕上按出这几个数字。 2、其次是计算考勤机的密码。计算考勤机密码需要工具,也就是计算器,打开手机上的计算器。 3、有了计算器,还需…

连接中控指纹考勤机 zkemkeeper zksoftware ZKTeco

使用vb.net连接中控指纹考勤机需要的软件:1.开发包工具: http://www.zksky.com/Products/Download/Downloadseven/ (我使 用的就是开发包下Demo文件,里面有3个文件夹对应不用的考勤机类型,注意是类型不是型号,不清楚就问考勤机公司…

Java spring boot 开发中控Live10R指纹采集器linux(指纹登录系统)

1.需求 需要做一个指纹登录系统,录入指纹,修改指纹等,指纹比对等。 2.开发 开启指纹采集器,指纹采集器base64数据录入到数据库以及指纹登录登出 package com.iot.modules.biz.fp;import com.iot.common.util.CommonUtil; import…

中控消费机一直显示连接服务器,中控消费机培训及常见问题的解决办法-1.ppt

《人教版历史第14课灿烂的宋元文化二 培训主题 消费机功能基本操作介绍 CM20集消费机,出纳机,补贴机功能于一体。机器的操作,分为机器操作和软件操作两大块。其中可以通过机器操作来实现消费机/出纳机/补贴机之间的切换。软件界面简洁清晰、操…

中控消费机一直显示连接服务器,中控消费机培训及常见问题的解决办法课件.ppt...

培训主题 消费系统培训 消费机功能基本操作介绍 CM20集消费机 出纳机 补贴机功能于一体 机器的操作 分为机器操作和软件操作两大块 其中可以通过机器操作来实现消费机 出纳机 补贴机之间的切换 软件界面简洁清晰 操作方便 功能齐全 系统稳定可靠 大大提升了管理效率 机器硬件核…

中控人脸指纹考勤机怎么如何偷偷修改数据记录

中控人脸指纹考勤机怎么如何偷偷修改数据记录在日常工作中,由于公司、单位、企业安装使用了人脸考勤机或指纹打卡机,进行员工考勤签到打卡管理,所以,很多员工或职员,都会按时上下班,自觉签到签退。可以说人…

中控H10考勤机管理员密码破解

中控H10考勤机管理员密码破解 标签:考勤机 管理员 密码破解 1. 管理员破解方式 首先看考勤机上的时间,比如显示为20:24,去掉冒号为2024管理员密码为: (9999−2024)263600625 长按M/OK键,进入管理员界面,输…

中控指纹考勤机软件登录用户名和密码忘记的解决办法

原文:http://tieba.baidu.com/p/2035038238 首先计算机必须安装了Office2000(要有access),然后进入考勤程序安装目录,找到Att2000.mdb文件,双击打开,在出现的界面中找到userinfo表,双…