[DeeplearningAI笔记]ML strategy_2_3迁移学习/多任务学习

来源:互联网 发布:淘宝刷天龙八部vip帐号 编辑:程序博客网 时间:2024/05/02 04:31

2.7 迁移学习 Transfer Learninig

  • 神经网络可以从一个任务中习得知识,并将这些知识应用到另一个独立的任务中.例如:你已经训练好一个能够识别猫的系统,你利用这些知识或者这些知识的部分去完成更好的 阅读X射线扫描图.
  • 这就是所谓的-- 迁移学习

how-to

  • 假设你已经训练好一个图像识别神经网络,首先用一个神经网络,在(x,y)对上训练,其中x是图像,y是对象的标签.

  • 现在把这个神经网络拿出来,将其适应(迁移)到不同任务中所学到的知识,比如放射科诊断.
  1. 把神经网络最后的输出层删除
  2. 进入到最后一层并将其权重删除
  3. 为最后一层重新赋予随机权重
  4. 然后将神经网络放在放射诊断数据上训练

Tips

  • 如果进行迁移学习的数据量比较小,只需要重新训练最后一两层权重.但是如果进行迁移学习的数据量较大,建议重新训练整个神经网络.
  • 预训练(pre-training): 如果重新训练所有神经网络层,那么在图像识别数据的初期训练阶段,我们称这个过程为:预训练
  • 微调(fine tuning): 在预训练后的模型上放入迁移学习的数据进行训练,这个过程称为:微调

why

  • 迁移学习的好处在于,以放射科图像检测的迁移学习为例 在预训练的过程中,我们学到了一些图像识别中低层次特征,很多结构信息,图像形状的信息,点,线,面的特征.-- 边缘检测(detecting edges),曲线检测(的tecting curves),阳性对象检测(detecting positive objects) 应用或迁移到放射科诊断上来.从非常大的图像识别数据库中习得的这些能力,会有助于你的学习算法在放射科诊断做的更好.

Another Example

cshici
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgxi.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgxg.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgxd.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgww.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgwv.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgwu.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgwt.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgwe.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgwj.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgwi.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgwd.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgwc.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgwb.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgwa.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgw6.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgw7.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgtz.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgty.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgtx.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgtw.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgtu.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgtt.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgts.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgtr.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgtq.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgtp.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgto.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgtn.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgtk.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgsh.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgsg.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgsf.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgse.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgsd.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgsc.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgsb.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgs3.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgs0.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgr4.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgqc.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgqb.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgqa.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgpp.html
http://blog.sina.com.cn/s/blog_175dc3f8a0102xgpo.html
链接反映
  • 假设你已经训练出一个语音识别系统(speech recognition system),现在x是音频(audio)或者音频片段输入(audio snippets),y是听写文本(transcript). 我们要使用这个系统"迁移学习"建立一个"唤醒词"的系统.
  • 你可能需要去掉神经网络的最后一层,然后加入新的输出节点.但有时也可以不止加入一个新节点,或者甚至往你的神经网络加入几个新层.然后把唤醒词检测问题的标签"Y"喂进去训练.
  • 这取决于你的训练数据的多少,你可能只需要重新训练网络的新层,也许你需要重新训练网络中更多的层.

when Transfer learning makes sence

  • 迁移来源问题你有很多数据,但迁移目标问题你没有那么多数据.
  • 例如:假如在图像识别任务中你有100W样本,数据量相当多,你可以学习低层次特征,可以在神经网络的前几层学到如何识别很多有用的特征.
    • 但是对于"放射科任务",也许你只有100个样本,所以你可以将图像识别预测的知识迁移到"放射科识别任务"中,即使你的放射科数据很少.
  • 例如:在"语音识别"任务中,也许你已经有1W小时数据,训练过你的语言识别系统.所以你已经从这1W小时数据中学到了很多人类声音的特征.
    • 但是对于"触发字检测",也许你只有1小时数据,所以这数据太小,不能用来拟合很多参数.
    • 所以这种情况下,你需要预先学到很多人类声音的特征,人类语言的组成部分等等知识,可以帮你建立一个很好的唤醒字检测器(wake word detector).即使你的数据集相对较小.

summary

  1. 如果你想从任务A迁移一些知识到任务B,当任务A和任务B都有相同的输入X时,迁移学习是有意义的.
  • 例如在第一个例子中,输入X都是图片;在第二个例子中X都是声音音频.
  1. 当任务A的数据比数据B多得多时,迁移学习意义更大.
  • 所有这些假设的前提都是,你希望提高任务B的性能.
  • 因为任务B的每个数据更有价值,对于任务B来说.通常任务A的数据量必须大得多,才有帮助.
  1. 如果你觉得任务A的低层次特征,可以帮助任务B的学习,那迁移学习更有意义一些.

2.8 多任务学习 Multi-task learning

  • 在迁移学习中,你的步骤是串行的,你从任务A里学到知识然后迁移到任务B中.在多任务学习中,你是同时开始学习的,试图让单个神经网络同时做几件事情,然后希望这里的每个任务都能帮到其他所有任务.

    Simplified autonomous driving Example

  • 假设你正在研发无人驾驶车辆,那么你的无人驾驶车可能需要同时检测不同的物体.(行人,车辆,停车标志,交通灯...)

  • 需要识别的物体假设即为上述讨论的四个,则最后一层设置4个神经元,一个4维向量,分别表示对"行人,车辆,停车标志,交通灯"的预测.

其中多任务学习 Loss function 也有相应的变化.对于多任务学习:

阅读全文
0 0
原创粉丝点击