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 calculating accuracy #42

Open
datduonguva opened this issue Jun 21, 2021 · 0 comments
Open

Question about calculating accuracy #42

datduonguva opened this issue Jun 21, 2021 · 0 comments

Comments

@datduonguva
Copy link

In calculating accuracy of test dataset:
https://github.com/floodsung/LearningToCompare_FSL/blob/master/omniglot/omniglot_train_one_shot.py#L237

sample_images,sample_labels = sample_dataloader.__iter__().next()                
test_images,test_labels = test_dataloader.__iter__().next()
            
sample_features = feature_encoder(Variable(sample_images).cuda(GPU)) # 5x64                
test_features = feature_encoder(Variable(test_images).cuda(GPU)) # 20x64
                            
sample_features_ext = sample_features.unsqueeze(0).repeat(SAMPLE_NUM_PER_CLASS*CLASS_NUM,1,1,1,1)                test_features_ext = test_features.unsqueeze(0).repeat(SAMPLE_NUM_PER_CLASS*CLASS_NUM,1,1,1,1)                test_features_ext = torch.transpose(test_features_ext,0,1)
relation_pairs = torch.cat((sample_features_ext,test_features_ext),2).view(-1,FEATURE_DIM*2,5,5)                relations = relation_network(relation_pairs).view(-1,CLASS_NUM)
 _,predict_labels = torch.max(relations.data,1)
 rewards = [1 if predict_labels[j]==test_labels[j] else 0 for j in range(CLASS_NUM)]

I think the reward must be summed over all images in the batch size, so the j in the last line should be in range(len(test_labels))

Why was it sum over j in CLASS_NUM?

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