Closed sunray42 closed 10 months ago
Describe the bug
def get_importance_weight(self, feature): """ Get importance weights for each instance. Args: feature (tensor): feature from source domain, in shape :math:`(N, F)` Returns: instance weight in shape :math:`(N, 1)` """ weight = 1. - self.discriminator(feature) weight = weight / weight.mean() weight = weight.detach() return weight
其中weight / weight.mean()可能会产生除0操作,导致nan。
weight / weight.mean()
增加条件判断 if weight.mean(): weight = weight / weight.mean()
if weight.mean(): weight = weight / weight.mean()
感谢指出这个bug,这里除的时候增加一个epsilon就可以了,我们会尽快修一下~
Describe the bug
其中
weight / weight.mean()
可能会产生除0操作,导致nan。增加条件判断
if weight.mean(): weight = weight / weight.mean()