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

LogQ in criterion.py #1

Closed
nviwch opened this issue Jul 30, 2021 · 3 comments
Closed

LogQ in criterion.py #1

nviwch opened this issue Jul 30, 2021 · 3 comments

Comments

@nviwch
Copy link

nviwch commented Jul 30, 2021

def logQ(self, gt_uv, pred_jts, sigma):
return torch.log(sigma / self.amp) + torch.abs(gt_uv - pred_jts) / (math.sqrt(2) * sigma + 1e-9)

from the function definition, it looks like the Q is laplacian distribution but Q = exp( - abs(x - mu) / b) / 2b, after taking log it is log(1/2b) - abs(x - mu) / b

when seeing loss = nf_loss + Q_logprob, nf_loss = log(sigma) - log_phi, compare with the paper saying loss = -log(Q(bar_mu)) +log(sigma)-log_phi, I guess the Q_logprob already has the negative sign inside but then, why it is not -log(1/2b) + abs(x-mu)/b? i.e. the first term torch.log(sigma / self.amp) should have the minus sign.

On the other hand, how do you choose the value of b? in the distribution sense, b = sqrt(variance / 2)

@Jeff-sjtu
Copy link
Owner

Hi @nviwch ,

The first term - log(1/2b) = log(2b) = log(sigma) + log(constant). Therefore, it is equivalent to torch.log(sigma). The constant term can be ignored when calculating loss.

For the second question, b = sqrt(varance * 2) = sqrt(2) * sigma in our implementation.

@nviwch
Copy link
Author

nviwch commented Jul 30, 2021

i don't know how I miss the next simple step. Sorry for my stupid question

@nviwch nviwch closed this as completed Jul 30, 2021
@sunyizeng
Copy link

As @nviwch pointed out b = sqrt(variance / 2) = sigma / sort(2)
But in the implementation, b = sqrt(varance * 2) = sigma * sqrt(2)
Is this a bug? @Jeff-sjtu

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

3 participants