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 ...
随机推荐
- 浅谈MySQL数据库面试必要掌握知识点
概述 **本人博客网站 **IT小神 www.itxiaoshen.com 定义 MySQL官方地址 https://www.mysql.com/ MySQL 8系列最新版本为8.0.27,5系列的最 ...
- day9 图书设计项目
总路由层url from django.conf.urls import url from django.contrib import admin from app01 import views ur ...
- day12 keepalived高可用
day12 keepalived高可用 一.高可用介绍 1.什么是高可用 部署在整个集群中的一个高可用软件,作用是创建一个VIP(虚拟IP),在整个集群中有且只有一个机器上生成VIP,当这台机器出现问 ...
- C++构造函数和析构函数初步认识
构造函数 1.构造函数与类名相同,是特殊的公有成员函数.2.构造函数无函数返回类型说明,实际上构造函数是有返回值的,其返回值类型即为构造函数所构建到的对象.3.当新对象被建立时,构造函数便被自动调用, ...
- window ntp服务
一.确定服务端和客户端处于同一网段,能相互 Ping 通. 二.服务器端(Server)配置 1.选择一台服务器(Windows 系统)作为时间同步服务器: 2.Win + R (运行 cmd 命令行 ...
- Output of C++ Program | Set 3
Predict the output of below C++ programs. Question 1 1 #include<iostream> 2 using namespace st ...
- @Conditional 注解,基于条件实例对象
.catalogue-div { position: relative; background-color: rgba(255, 255, 255, 1); right: 0 } .catalogue ...
- 使用springboot配置和注入数据源属性的方法和步骤
/** 1.书写一个名为resources/application.properties的属性文件---->书写一个配置属性类,类名为: **/ 文件:application.propertie ...
- 12.Vue.js 表单
这节我们为大家介绍 Vue.js 表单上的应用. 你可以用 v-model 指令在表单控件元素上创建双向数据绑定. <div id="app"> <p>in ...
- python中的虚拟环境(在jupyter和pycharm中的使用)
1.通过anaconda新建虚拟环境 创建虚拟环境:conda create -n your_env_name python=3.6 激活虚拟环境:activate your_env_name(虚拟环 ...