CS330 lecture 1&2 notes

Informal Problem Definitions

  • The multi-task learning problem: Learn all of the tasks more quickly or more proficiently than learning them independently.(更快更专业学习所有任务)
  • The meta-learning problem: Given data/experience on previous tasks, learn a new task more quickly and/or more proficiently.(依照先前任务的经验,更快更好的学习新任务)

Multi-Task Learning Basics

传统单任务学习 Single-task learning:

D={(x,y)k}minθL(θ,D) \begin{array}{l}{\mathscr{D}=\left\{(\mathbf{x}, \mathbf{y})_{k}\right\}} \\ {\min _{\theta} \mathscr{L}(\theta, \mathscr{D})}\end{array}

损失函数 Typical loss: negative log likelihood

L(θ,D)=E(x,y)D[logfθ(yx)] \mathscr{L}(\theta, \mathscr{D})=-\mathbb{E}_{(x, y) \sim \mathscr{D}}\left[\log f_{\theta}(\mathbf{y} | \mathbf{x})\right]

What’s a task?

A task: Ti{pi(x),pi(yx),Li}\mathscr{T}_{i} \triangleq\left\{p_{i}(\mathbf{x}), p_{i}(\mathbf{y} | \mathbf{x}), \mathscr{L}_{i}\right\}

data generating distributions

这里将任务定义成,数据样本的分布,数据标签的分布和损失函数

Corresponding datsets:Ditr\mathscr{D}_{i}^{tr} 训练集Ditst\mathscr{D}_{i}^{t s t}测试集 通常用Di\mathscr{D}_{i}表示训练集

Multi-task classification:Li\mathscr{L}_{i} same across all tasks 例如:每种语言的手写识别中,损失函数的形式可能相同

Multi-label learning:Li,pi(x)\mathscr{L}_{i}, {p}_{i}(x) same across all tasks 例如:CelebA 多标签识别任务中,样本和损失函数都是相同的

在以下任务中损失函数可能会发生不同的变化:

  • mixed discrete, continuous labels across tasks(混了了离散和连续的标签的任务)
  • care more about one task than another(任务之间权重不同?)

Conditioning on the task

对于multi task learning的问题需要引入一个task descriptor作为描述任务的变量,那么如何设计这个变量。

假设zi{z}_{i}是task index,那么最直接的办法就是multiplicative gating,也就使得这个多任务学习中的每个任务是独立的用单独网络训练而不分享参数。

那么另一种极端就是直接concatziz_i,那样所有参数都会被共享,除了输入ziz_i之后的参数。

那么另一种思路就是吧θ\theta分为shared parameters θsh\theta^{sh}和task-specific parametes θi\theta^i也就是共享参数和不共享参数

那么优化目标就变成了

minθsh,θ1,,θTi=1TLi({θsh,θi},Di) \min _{\theta^{s h}, \theta^{1}, \ldots, \theta^{T}} \sum_{i=1}^{T} \mathscr{L}_{i}\left(\left\{\theta^{s h}, \theta^{i}\right\}, \mathscr{D}_{i}\right)

问题就转化成了如何选择和什么时候共享参数

Common Choices

常用的方法主要有拼接和加法,看图一目了然

  1. Concatenation-based conditioning(拼接)

cs330-1-1.png

  1. Additive conditioning(加法)

cs330-1-2.png

实际上两者是等同的

cs330-1-3.png

  1. Multi-head architecture

cs330-1-4.png

  1. Multiplicative conditioning

cs330-1-5.png

乘法的方法可以带来

  • 更强的表达能力
  • 对于回归任务,有multiplication gating
  • 能够对于独立的网络和heads进行更好的泛化

Complex Choices

还有许多其他复杂的方式

cs330-1-6.png

但是设计的灵感来源问题就和神经网络的参数选择一样:

  • 不同问题之间是独立的
  • 对于特定的问题,主要依靠设计者的直觉和背景知识
  • 目前解决的方法更像是艺术而非科学

Optimizing the objective

Objective:minθi=1TLi(θ,Di)\min _{\theta} \sum_{i=1}^{T} \mathscr{L}_{i}\left(\theta, \mathscr{D}_{i}\right)

一般的流程:

  1. 从tasks中采样一个minibatchB{Ti}\mathscr{B} \sim\left\{\mathscr{T}_{i}\right\}
  2. 从每个task中采样一个minibatch的数据样本DibDi\mathscr{D}_{i}^{b} \sim \mathscr{D}_{i}
  3. 在每个minibatch-task上计算loss:L^(θ,B)=TkBLk(θ,Dkb)\hat{\mathscr{L}}(\theta, \mathscr{B})=\sum_{\mathcal{T}_{k} \in \mathscr{B}} \mathscr{L}_{k}\left(\theta, \mathscr{D}_{k}^{b}\right)
  4. 反向传播计算梯度θL^\nabla_{\theta} \hat{\mathscr{L}}
  5. 采用你喜欢的优化器更新梯度

Note:这样可以保证无论数据量如何,任务都可以被均匀采样 Tip:对于回归任务,确保任务标签是相同的scale

Challenge

  1. Negative transfer

在cifar-100上进行多任务训练,不如独立训练。

可能的原因:

  • 来自优化方面的挑战
    • 不同任务之间的相互干扰
    • 不同任务的学习速率不同
  • 受限的表达能力
    • 多任务网络体积较大

解决方法:

share less across task(软参数分享)

  • allows for more luid degrees of parameter sharing 好处
  • yet another set of design decisions/hyperparameters 坏处
minθsh,θ1,,θTi=1TLi({θsh,θi},Di)+t=1Tθtθt \min _{\theta^{sh}, \theta^{1}, \ldots, \theta^{T}} \sum_{i=1}^{T} \mathscr{L}_{i}\left(\left\{\theta^{s h}, \theta^{i}\right\}, \mathscr{D}_{i}\right)+\sum_{t=1}^{T}\left\|\theta^{t}-\theta^{t'}\right\|

后面的部分就是软参数分享,就是将第二个task的参数和前一个的差作为优化项,相当于让每个task的参数尽可能相似,也就是分享了参数。

  1. Overfitting

过拟合原因一般是由于,参数共享的不够多,解决方案就是参数分享的更多一些。可以理解为,分享的不够,使得每个task都过拟合了,类似于独立训练了。

Meta-Learning Basics

元学习的两种视角

  • Mechanistic view (机制视角)
    • 可以读取整个数据集并且对新的数据进行预测的深度神经网络
    • 利用元数据集对网络进行训练,并且这种元数据集针对不同的任务包含了不同的数据集
    • 这种视角可以容易实现一个元学习算法。
  • Probabilistic view(概率视角)
    • 从一系列元学习任务重提取先验知识
    • 使用少量的数据和先验信息推测出相对有效的后验参数
    • 这种视角可以更好地理解元学习算法

Problem definitions

首先回顾一下监督学习: cs330-1-7.png

存在的问题:

  • 需要大量的标记数据
  • 目前的某些任务数据标签很有限

To be continued