Understanding Black-box Predictions via Influence Functions
@article{koh2017understanding,
title={Understanding black-box predictions via influence functions},
author={Koh, Pang Wei and Liang, Percy},
pages={1885--1894},
year={2017}}
概
本文介绍了如果计算(估计)损失关于样本的一些影响因子, 并介绍了一些应用范围.
主要内容
假设样本\(z_1,\ldots, z_n\), \(z_i = (x_i,y_i) \in \mathcal{X} \times \mathcal{Y}\), 通过最小化经验损失
\]
找到最优解.
且假设\(L\)关于样本和参数都是二阶可导且强凸的.
样本重要性分析
显然, 此时给定一个测试样本\(z_{test}\), 其对应的损失为\(L(z_{test},\hat{\theta})\), 那么衡量一个样本重要性的一个重要指标便是, 倘若在移除样本\(z\)的情况下重新训练模型, 对应的参数和损失的变化.
假设在移除样本\(z\)的情况下训练得到的最优参数为\(\hat{\theta}_{-z}\), 并引入
\]
易得\(\hat{\theta}_{-z} = \hat{\theta}_{-\frac{1}{n},z}\).
则
\mathcal{I}_{up, params} (z) := \frac{d \hat{\theta}_{\epsilon, z}}{d \epsilon}|_{\epsilon=0} = -H_{\hat{\theta}}^{-1} \nabla_{\theta} L(z, \hat{\theta}),
\]
其中\(H_{\theta}:= \frac{1}{n} \sum_{i=1}^n \nabla_{\theta}^2 L(z_i, \hat{\theta})\).
我们可以得到, 参数的变化量的一阶近似
\]
进一步, 我们定义损失的变化量
\begin{array}{ll}
\mathcal{I}_{up, loss} (z, z_{test})
& := \frac{dL(z_{test}, \hat{\theta}_{\epsilon, z})}{d \epsilon} |_{\epsilon = 0} \\
& = \nabla_{\theta} L(z_{test}, \hat{\theta})^T \frac{d \hat{\theta}_{\epsilon, z}}{d \epsilon} |_{\epsilon = 0} \\
& = -\nabla_{\theta} L(z_{test}, \hat{\theta})^T H_{\hat{\theta}}^{-1} \nabla_{\theta} L(z, \hat{\theta}).
\end{array}
\]
样本摄动对损失的影响
倘若我们对其中一个样本\(z\)添加一个扰动\(\delta\), 并在新的数据\(z_{\delta}:=(x+\delta,y)\)上训练, 得到模型, 其参数和损失会如何变化?
我们定义
\]
并令\(\hat{\theta}_{z_{\delta},-z}:= \hat{\theta}_{\frac{1}{n}, z_{\delta}, -z}\)
同样可以证明
\frac{d \hat{\theta}_{\epsilon, z_{\delta}, -z}}{d \epsilon} |_{\epsilon=0} = -H_{\hat{\theta}}^{-1} (\nabla_{\theta} L(z_{\delta}, \hat{\theta}) -\nabla_{\theta} L(z, \hat{\theta})).
\]
则
\]
故
\mathcal{I}_{pert, loss}(z, z_{test})^T:= \nabla_{\delta} L(z_{test}, \hat{\theta}_{z_{\delta},-z})^T \approx -\frac{1}{n} \nabla_{\theta} L(z_{test}, \hat{\theta})^T H_{\hat{\theta}}^{-1} \nabla_x \nabla_{\theta} L(z, \hat{\theta}).
\]
注:文章这里没有\(\frac{1}{n}\)且是等号(我卡在这个地方了, 推不出来).
高效计算\(H^{-1}\)
共轭梯度
此时我们不是计算\(H_{\hat{\theta}}^{-1}\), 而是计算\(s:=H_{\hat{\theta}}^{-1}v\), 比如在计算\(\mathcal{I}_{up, loss}\)的时候, \(v=\nabla_{\theta} L(z_{test}, \hat{\theta})\), 则对于固定的\(z_{test}\)想要知道不同的\(z_i\)的影响可以直接用\(s^T \nabla_{\theta} L(z_i, \hat{\theta})\), 避免了重复运算.
即求解
\]
假设第\(k\)步为
\]
则利用精确直线搜索
\]
得
\]
随机估计
这里是估计\(H_{\hat{\theta}}^{-1}\), 为了符号简便省略下表, 因为\(H^{-1}=\sum_{i=0}^{+\infty}(I-H)^i\), 用\(H_j^{-1}= \sum_{i=0}^j (I - H)^i\)表示前\(j+1\)项的和, 易知
\]
我们从样本中均匀挑选, 计算\(\nabla_{\theta}^2 L(z_i, \hat{\theta})\) 作为\(H\)的替代, 则
\]
当然, 处于稳定性的考虑, 我们可以一次性采样多个来作为\(H\)的替代.
一些应用
- 探索模型关于样本的内在解释, 即什么样的样本模型会更加偏好之类的;
- 生成对抗样本;
- 检测目标数据分布和训练分布是否一致;
- 检测训练数据的标签是否正确.
附录
(1)的证明
定义\(\Delta_{\epsilon}:= \hat{\theta}_{\epsilon, z}-\hat{\theta}\), 则
\]
由一阶最优条件可知
0= R(\hat{\theta}_{\epsilon, z}) + \epsilon \nabla_{\theta} L(z, \hat{\theta}_{\epsilon, z}),
\]
把\(\hat{\theta}_{\epsilon, \theta}\)看成自变量(固定\(\epsilon\)), 第二个等式右边是关于这个变量的一个函数, 则其在\(\hat{\theta}_{\epsilon, \theta}=\hat{\theta}\)处的泰勒展式为
\]
故
\]
因为\(\epsilon \rightarrow 0\), \(\Delta_{\epsilon} \rightarrow0\) 易知,
\]
Understanding Black-box Predictions via Influence Functions的更多相关文章
- THE BOX MODEL
Review In this lesson, we covered the four properties of the box model: height and width, padding, b ...
- [JS Compose] 1. Refactor imperative code to a single composed expression using Box
After understanding how Box is, then we are going to see how to use Box to refacotr code, to un-nest ...
- 【54】目标检测之Bounding Box预测
Bounding Box预测(Bounding box predictions) 在上一篇笔记中,你们学到了滑动窗口法的卷积实现,这个算法效率更高,但仍然存在问题,不能输出最精准的边界框.在这个笔记中 ...
- [C6] Andrew Ng - Convolutional Neural Networks
About this Course This course will teach you how to build convolutional neural networks and apply it ...
- Coursera机器学习+deeplearning.ai+斯坦福CS231n
日志 20170410 Coursera机器学习 2017.11.28 update deeplearning 台大的机器学习课程:台湾大学林轩田和李宏毅机器学习课程 Coursera机器学习 Wee ...
- directive(指令里的)的compile,pre-link,post-link,link,transclude
The nitty-gritty of compile and link functions inside AngularJS directives The nitty-gritty of comp ...
- What is “Neural Network”
Modern neuroscientists often discuss the brain as a type of computer. Neural networks aim to do the ...
- Angular1.x directive(指令里的)的compile,pre-link,post-link,link,transclude
The nitty-gritty of compile and link functions inside AngularJS directives The nitty-gritty of comp ...
- Convolution Fundamental II
Practical Advice Using Open-Source Implementation We have learned a lot of NNs and ConvNets architec ...
随机推荐
- day02 MySQL基本操作
day02 MySQL基本操作 昨日内容回顾 数据库演变史 1.纯文件阶段 2.目录规范 3.单机游戏 4.联网游戏 # 数据库就是一款帮助我们管理数据的程序 软件开发架构及数据库本质 cs架构与bs ...
- UBI 文件系统之分区挂载
Linux 系统中有关mtd和ubi的接口:(1) cat /proc/mtd:可以看到当前系统的各个mtd情况,(2) cat /proc/partitions: 分区信息,有上面的类似(3) ca ...
- 复制virtualbox虚拟硬盘
D:\VirtualBox\VBoxManage.exe clonevdi F:\virtualbox\rac1\rac1.vdi F:\virtualbox\rac2\rac2.vdi 虚拟机软件安 ...
- 【分布式】Zookeeper客户端基本的使用
与mysql.redis等软件一样,zookeeper的软件包中也提供了客户端程序用于对服务器上的数据进行操作.本节我们就来学习zookeeper客户端的使用方法.不过在详细讲解zk客户端的使用方法之 ...
- c学习 - 第四章:顺序程序设计
4.4 字符数据的输入输出 putchar:函数的作用是想终端输出一个字符 putchar(c) getchar:函数的作用是从输入设备获取一个字符 getchar(c) 4.5 格式输入与输出 pr ...
- oracle中分组中的ROLLUP和CUBE选项
在进行多列分组统计时,如果直接使用GROUP BY子句指定分组列,则只能生成基于所有分组列的统计结果.如果在GROUP BY子句中使用ROLLUP语句或CUBE语句,除了生成基于所有指定列的分组统计外 ...
- excel数据导入mySql数据库
1.将excel数据保存好 2.打开数据库,在表上点击右键,选择导入向导 3.点击下图中红色部门,点击下一步 4.选择excel文件的位置,下方的表空间内,会出现excel中的sheet页,选择要导入 ...
- 基于spring sringmvc mybatis 做的导入导出
导入 pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://ww ...
- C# 使用modbus 读取PLC 寄存器地址
使用的组件Nmodbus 定义参数,全局变量: //创建modbus实体对象 private static ModbusFactory modbusFactory; private static IM ...
- JDK各版本新增的主要特性总结
JDK1.5新特性: 1.自动装箱与拆箱: 2.枚举 3.静态导入,如:import staticjava.lang.System.out 4.可变参数(Varargs) 5.内省(Introspec ...