daoyuan98 / MSDA

Experiments on Multi-Source Domain Adaptation
22 stars 5 forks source link

Question about how to select domain labels #3

Open Freak0728 opened 3 years ago

Freak0728 commented 3 years ago

Hi, I am lucky to see your code, it helps me a lot, but one thing I can't understand is how to choose domain labels when calculating domain loss. I would appreciate it if you could answer this question.

daoyuan98 commented 3 years ago

Hi, thank you for your interests in the code. The domain loss is actually calculated by a binary classification loss. Suppose there are source domains, {S1, S2, ..., Sk}, we calculate k domain losses by differentiating each source and the target domain T. For each source-target pair {Si, T}, the domain label is either 0 or 1.

Freak0728 commented 3 years ago

Thank you for your reply, I saw your code address from the issue reply under MDAN code. I don't know if you have seen the code of the article "MDAN: Multiple Source Domain Adaptation with Adversarial Learning", the code address is as follows: https://github.com/hanzhaoml/MDAN. In its Amazon sentiment analysis experiment, when calculating the domain loss, the source label was set to all 1 and the target label was set to all 0. I just don't understand the principle of this. The code is as follows: domain_losses = torch.stack([F.nll_loss(sdomains[j], slabels) + F.nll_loss(tdomains[j], tlabels) for j in range(num_domains)])

daoyuan98 commented 3 years ago

Hi, I personally think this should not influence the results as long as the domain label is consistent across all source-target pairs, i.e. always set source=1&target=0 or source=0&target=1.

Freak0728 commented 3 years ago

Okay, thanks very much, I understand it roughly!