thuml / Transfer-Learning-Library

Transfer Learning Library for Domain Adaptation, Task Adaptation, and Domain Generalization

Home Page:http://transfer.thuml.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

关于DST equation 7 (Debiased Self-Training for Semi-Supervised Learning)

gufan-d opened this issue · comments

commented

作者您好,抱歉打扰了。我刚接触半监督学习,您的DST工作对我启发很大,有关于公式7的实现有些不明白想请教您一下。

    def forward(self, y_l, y_l_adv, y_u, y_u_adv):
        _, prediction_l = y_l.max(dim=1)
        loss_l = self.eta_prime * F.cross_entropy(y_l_adv, prediction_l)

        _, prediction_u = y_u.max(dim=1)
        loss_u = F.nll_loss(shift_log(1. - F.softmax(y_u_adv, dim=1)), prediction_u)

        return loss_l + loss_u

这里1. - F.softmax(y_u_adv, dim=1)是要鼓励loss_u向相反的方向收敛吗?不太明白
希望能得到您的指点,不胜感激!

文中的Equation 7是feature extractor的优化目标,在我们的方法中,worst head和feature extractor是对抗训练的,其目标是在labeled data上和main head尽可能一致而在unlabeled data上找到与main head尽量不同的假设,因此这里的实现就是鼓励y_u_adv增大和y_u的差异

commented

好的,感谢您的解答。我还有一点不清楚,公式7中用有监督loss减去无监督loss,代码中是用梯度翻转层和1. - F.softmax(y_u_adv, dim=1实现的吗?

梯度反转层实现了feature extractor和worst head之间的对抗,有监督loss减去无监督loss我个人感觉从假设空间的角度更好理解,就像上面说的在labeled data上和main head尽可能一致而在unlabeled data上找到与main head尽量不同的假设,具体实现是通过计算F.nll_loss(shift_log(1. - F.softmax(y_u_adv, dim=1)), prediction_u),这里与main head尽量不同的假设就是1. - F.softmax(y_u_adv, dim=1)

commented

感谢您的解答!