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

Partial Adversarial Domain Adaptation #146

Closed zhangyl660 closed 2 years ago

zhangyl660 commented 2 years ago

您好,请问pada.py中,为什么对目标域采用(取源域权重平均值)的方式定义权重? class_weight_adv_target = torch.ones_like(class_weight_adv_source) * class_weight_adv_source.mean() 论文中似乎只对源域定义了权重

thucbx99 commented 2 years ago

这里起到一个类似于normalize的作用。从class的角度来说,target上的每个class实际上权重是一样的(因此和PADA对于source上class的计算方式是不一样的),从domain的角度来说,乘以这一项保证了source domain和target domain的样本在对抗训练过程中期望的权重是一样的,这样也更合理一些,因为我们可能不知道source和target中的哪一个需要更大的权重。

zhangyl660 commented 2 years ago

明白了,谢谢您!

thucbx99 commented 2 years ago

不客气~