davidpengucf / SFDAHPE

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Some problem with loss_im(SimCCLoss)

Howard-Hsiao opened this issue · comments

Hello, I have some confusion regarding the information maximization loss while reading your paper. After reviewing your train_sfda.py file, I noticed that the implementation of loss_im seems to deviate from what is described in the paper.

  1. In the paper, loss_im should be calculated based on the output of the target model, but in the code, it is computed based on the output of the intermediate model.
    loss_im = im_criterion(y_t_in, y_t_tg)
class SimCCLoss(nn.Module): # used as im_criterion
    def __init__(self, reduction='mean'):
        super(SimCCLoss, self).__init__()
        self.reduction = reduction

    def forward(self, x, threshold=-1):
  1. The paper does not mention the inclusion of a threshold in the design of loss_im, but in your code, the output of the target model is passed to SimCCLoss as a threshold for calculation (The initial parameter x for the im_criterion is set to y_t_in.).

  2. In SimCCLoss, y_t_tg is used as a threshold for calculation. Nevertheless, encountering an if statement such as if threshold > 0 in SimCCLoss will result in the following error.
    The position of code that lead to error: if threshold > 0:
    RuntimeError: Boolean value of Tensor with more than one value is ambiguous