简述

  • 需求背景
    多任务学习的需求比较普遍, 比如给定一篇doc(如 博客, 微博, 短新闻) 的文本信息和数字信息(如 长度, 图片数, 发表日期), 来预测点赞, 转发, 点击率 等若干个回归值.
  • 为什么可以多任务训练
    有些隐藏特征可以共用, 这是各output可以公用前几层的理论假设.
    除了一石二鸟, 训练一次实现多种用途以外, 多个 output 之间也会相互平衡, 像正则项一样, 比单一任务达到更好的泛化效果.

网络结构

神经网络中的多任务学习
figure multi-input-multi-output-graph

compile in keras

keras.engine.training.Model#compile(self, optimizer, loss, metrics=None, loss_weights=None,
sample_weight_mode=None, weighted_metrics=None,
target_tensors=None, **kwargs)

  • loss
    可以传一个list, 对应每个output 的损失函数.
  • loss_weights
    可选的, 指定每个output所用损失函数的权重.
    The loss value that will be minimized by the model will then be the weighted_sum of all individual losses.

fit in keras

fit(x,y)函数中的y传一个list, 与各output对应即可.

参考

  1. keras official guide doc multi-input-and-multi-output-models

相关文章:

  • 2021-10-13
  • 2021-04-06
  • 2021-10-21
  • 2021-08-27
  • 2021-04-12
  • 2022-12-23
猜你喜欢
  • 2021-07-02
  • 2021-10-27
  • 2023-03-23
  • 2021-09-08
  • 2022-12-23
  • 2021-09-27
  • 2021-11-27
相关资源
相似解决方案