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

Undercounting Batches in Accuracy Calculation #2

Open
ztosi opened this issue Jan 12, 2022 · 1 comment
Open

Undercounting Batches in Accuracy Calculation #2

ztosi opened this issue Jan 12, 2022 · 1 comment

Comments

@ztosi
Copy link

ztosi commented Jan 12, 2022

Hi there, nice project! I've actually been using it as a base for some of my own work on scaling CDN on HPC systems. In doing that I noticed a bug, though:

def test_nn(model: Network, test_loader: DataLoader):

In test_nn where you calculate accuracy, you set the counter used as the denominator equal to the batch_idx, which undercounts the number of batches by one. In the limit, one can imagine a case where the entire dataset is a single batch and in that case "count" would be 0.

I was using a fairly large batch size and getting really inflated accuracy numbers.

@sash-a
Copy link
Owner

sash-a commented Mar 31, 2022

Hey sorry for getting back to you so late, I don't think I got a notification.

Good catch, I think the cleanest fix would probably be:

for batch_idx, (inputs, targets) in enumerate(test_loader, 1):

You can open a PR if you want 😄

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

2 participants