dragen1860 / LearningToCompare-Pytorch

Pytorch Implementation for CVPR2018 Paper: Learning to Compare: Relation Network for Few-Shot Learning
251 stars 48 forks source link

type issue in accuracy #1

Closed fguney closed 6 years ago

fguney commented 6 years ago

for me, the accuracy was always zero because of a type issue. If you sum a boolean array like this

correct = torch.eq(pred, query_y).sum()

it is always either 0 or 1. I had to change it to:

correct = torch.eq(pred, query_y).float().sum()

Maybe it's a version difference only.

dragen1860 commented 6 years ago

Hi, sum() function will count the number of one element in byte tensor. I don't think you should convert it to float type. Maybe it's a version problem. Let's see what the version of your pytorch.

fguney commented 6 years ago

0.3.0.post4

dragen1860 commented 6 years ago

You are using py27? I reccomend you run it by py36 since I tested on py36.

fguney commented 6 years ago

but I got nice results on my data. Ok, thanks for the warning. I will run your experiments on MiniImagenet and compare to your results to make sure :)