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

Question about the ADE in metrics.py #4

Closed
MeimingWang opened this issue Sep 15, 2020 · 1 comment
Closed

Question about the ADE in metrics.py #4

MeimingWang opened this issue Sep 15, 2020 · 1 comment

Comments

@MeimingWang
Copy link

Hi, thanks for sharing your codes. You have done a great job. But I have a question about the ADE in the codes:

def avg_disp(y_pred, y_true):
""" Average displacement error. """
y_true, masks = y_true
seq_lengths = masks.sum(1)
batch_size = len(seq_lengths)
squared_dist = (y_true - y_pred)**2
l2_dist = masks * torch.sqrt(squared_dist.sum(2))
avg_l2_dist = (1./batch_size) * ((1./seq_lengths) * l2_dist.sum(1)).sum()
return avg_l2_dist.item()

avg_l2_dist = (1./batch_size) * ((1./seq_lengths) * l2_dist.sum(1)).sum()
Why do you still multiply 1./batch_size while you have already multiplied 1./seq_lengths. I can't figure out the reason. Let's assume that all the positions in the predicted trajectory are valid, which means seq_legths = 12 and batch_size = 12. So in your code, you divide the l2_dist.sum(1) by 12*12. I think the right way is to divide it by 12. Could you tell me the reason why you do that?

@MeimingWang
Copy link
Author

After running the codes, I find that I was wrong. batch_size = 1 not 12 in final result. Anyway, thanks for your sharing!

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