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

error at accuracy #23

Open
hahmyg opened this issue Jan 2, 2020 · 0 comments
Open

error at accuracy #23

hahmyg opened this issue Jan 2, 2020 · 0 comments

Comments

@hahmyg
Copy link

hahmyg commented Jan 2, 2020

Dear author

Thank you for your carefully written code.
I re-use your some codes, and I found out the error

please check the line 84 in prototypical_loss.py
I think y_hat should be sequeezed with squeeze()

y_hat and target_inds.squeeze() look like:

y_hat = torch.tensor([[0],[1],[2],[0],[4]])
target_inds.squeeze() = torch.tensor([0, 1, 2, 3, 4])

In this case,

y_hat.eq(target_inds.squeeze()).float()

tensor([[1., 0., 0., 0., 0.],
        [0., 1., 0., 0., 0.],
        [0., 0., 1., 0., 0.],
        [1., 0., 0., 0., 0.],
        [0., 0., 0., 0., 1.]])

In this case, accuracy is 0.2

It should be tensor([1., 1., 1., 0., 1.]).
In this case, accuracy is 0.8

rcy17 added a commit to rcy17/Prototypical-Networks-for-Few-shot-Learning-PyTorch that referenced this issue Feb 3, 2021
belerico added a commit that referenced this issue Apr 5, 2022
Fix prototypical_loss bug #23
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