dragen1860/LearningToCompare-Pytorch

type issue in accuracy

Closed this issue · 4 comments

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.

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.

0.3.0.post4

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

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 :)