Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KDLoss and KLDiscretLoss difference , KDLoss mistake #92

Open
CatDroid opened this issue Aug 6, 2024 · 0 comments
Open

KDLoss and KLDiscretLoss difference , KDLoss mistake #92

CatDroid opened this issue Aug 6, 2024 · 0 comments

Comments

@CatDroid
Copy link

CatDroid commented Aug 6, 2024

in KLDiscretLoss (classification_loss.py)
log_pt's or labels's shape is [BK, width] or [BK, height]
width or height is ‘number of categories'

def criterion(self, dec_outs, labels):
   ......
  loss = torch.mean(self.kl_loss(log_pt, labels), dim=1)  
   ......

it will calculate the mean KL divergence of 'a key point x coordinate' on ' all categories'(along the dim=1 dimension)

but in KDLoss (kd.py)

def loss(self, logit_s, logit_t, beta, weight):
    ......
    loss_all = torch.sum(self.kl_loss(s_i, t_i), dim=1)
    ......

it will calculate the sum of KL divergence along dim=1 dimension .

does doing this have a different meaning?

Beside, in 'def loss(self, logit_s, logit_t, beta, weight):' if 'if len(logit_s.shape) == 3:' not true, K is not defined , maybe a mistake ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant