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

Small Bugs in how you populate the memory bank in Test.py #29

Open
dzlin99 opened this issue Apr 29, 2022 · 0 comments
Open

Small Bugs in how you populate the memory bank in Test.py #29

dzlin99 opened this issue Apr 29, 2022 · 0 comments

Comments

@dzlin99
Copy link

dzlin99 commented Apr 29, 2022

In test.py on line 26 and on 84, you guys have the following lines

temploader = torch.utils.data.DataLoader(trainloader.dataset, batch_size=100, shuffle=False, num_workers=1)
           for batch_idx, (inputs, targets, indexes) in enumerate(temploader):
                batchSize = inputs.size(0)
                features = net(inputs)
                features = torch.nn.functional.normalize(features)
                trainFeatures[:, batch_idx * batchSize:batch_idx * batchSize + batchSize] = features.data.t()

However, say you have a batch size of 100 in a dataset of length 450. On your last line in trainFeatures, the batch size will be 50, and instead of changing indices 400-450 while repopulating, you guys will be changing 200-250 as batch_idx * batch_size is 4 * 50 + 50 instead of 4 * 100 + 50. It should instead be something

orginal_batch_size = 100
temploader = torch.utils.data.DataLoader(trainloader.dataset, batch_size=original_batch_size, shuffle=False, num_workers=1)
           for batch_idx, (inputs, targets, indexes) in enumerate(temploader):
                batchSize = inputs.size(0)
                features = net(inputs)
                features = torch.nn.functional.normalize(features)
                trainFeatures[:, batch_idx * original_batch_size:batch_idx * original_batch_size + batchSize] = features.data.t()
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