thuml / Transfer-Learning-Library

Transfer Learning Library for Domain Adaptation, Task Adaptation, and Domain Generalization
http://transfer.thuml.ai
MIT License
3.39k stars 553 forks source link

关于Debiased Self-Training的问题 #212

Closed PpxiA6 closed 1 year ago

PpxiA6 commented 1 year ago

作者你好,最近阅读到你们这篇Debiased Self-Training文章,对我近期的项目很有启发,十分感谢你们做的工作,我想请问下原文中式7在代码中如何体现的呢?WorstCaseEstimationLoss是用于获取最坏情况的分类头,但是我好像没找到如何在这个最坏的分类头上优化特征表示用于提升最坏分类头的性能,恳请作者能够指点一下,十分感谢。

thucbx99 commented 1 year ago

可以参考这里的实现https://github.com/thuml/Transfer-Learning-Library/blob/c626a215e35cdb66c5a75efa4e43a42e2a1dd24e/projects/dst/dst.py#L41

具体来说,在line54我们定义了一个梯度反转层,其作用为使得backbone和worst head的目标相反,即进行对抗的训练(line84-85)

训练worst head的目标函数实现在https://github.com/thuml/Transfer-Learning-Library/blob/c626a215e35cdb66c5a75efa4e43a42e2a1dd24e/tllib/self_training/dst.py#L103

其在labeled data上和main head输出尽可能一致,而在unlabeled data上和main head输出尽可能不一致