fangpin / siamese-pytorch

Implementation of Siamese Networks for image one-shot learning by PyTorch, train and test model on dataset Omniglot
285 stars 62 forks source link

While testing with two dissimilar images (entirely two different subjects) your code says that they are same. #5

Closed Sumes closed 4 years ago

Sumes commented 6 years ago

While testing with two dissimilar images (entirely two different subjects) your code says that they are same.

fangpin commented 6 years ago

Hi @Sumes! I can not provide any help with this limited information. Did you use the newest version of this rep? What's your pytorch version? What's the output of your training process, in which I output the prediction accuracy on test dataset after every 100 mini-batchs. You still train your model with batch_size = 1? Anyway, that will be very helpful for our discussion if you can provide your code and output in a jupyter/ipython file.

Sumes commented 6 years ago

I did not modify your code. can you please check the output with test batch size equal to one for two entire two image sets (parallely)? I think the problem is the with pred = np.argmax(output)

This gives output as zero even if the images are different.

On Fri, Nov 16, 2018 at 7:37 AM Pin,Fang notifications@github.com wrote:

Hi @Sumes https://github.com/Sumes! I can not provide any help with this limited information. Did you use the newest version of this rep? What's your pytorch version? What's the output of your training process, in which I output the prediction accuracy on test dataset after every 100 mini-batchs. You still train your model with batch_size = 1? Anyway, that will be very helpful for our discussion if you can provide your code and output in a jupyter/ipython file.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fangpin/siamese-pytorch/issues/5#issuecomment-439257176, or mute the thread https://github.com/notifications/unsubscribe-auth/AoXVSzQGyR1CxaMu0tfaihpF9ZwazP6nks5uvh3hgaJpZM4YfsIJ .

Sumes commented 6 years ago

I did not modify your code. can you please check the output with test batch size equal to one for two entire two image sets (in parallel)? I think the problem is the with pred = np.argmax(output)

pred value is zero even if the images are different.

fangpin commented 6 years ago

Please refer to this function: https://github.com/fangpin/siamese-pytorch/blob/c2b1567dc70539f4eddd2935df0c7140309cf20d/mydataset.py#L96. There is trick to sample test data. I record the target image in self.img1 and always put the image whose class is same as self.img1 into the first position of each mini-batch. So if the model makes a right prediction, the 'pred = np.argmax(output)' should be 0. Hope that will be helpful. @Sumes

Sumes commented 6 years ago

Will you please test that with two entirely different images and see what pred is returning?

On Fri, Nov 16, 2018 at 5:35 PM Pin,Fang notifications@github.com wrote:

Please refer to this function: https://github.com/fangpin/siamese-pytorch/blob/c2b1567dc70539f4eddd2935df0c7140309cf20d/mydataset.py#L96 . There is trick to sample test data. I record the target image in self.img1 and always put the image whose class is same as self.img1 into the first position of each mini-batch. So if the model makes a right prediction, the 'pred = np.argmax(output)' should be 0. Hope that will be helpful. @Sumes https://github.com/Sumes

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fangpin/siamese-pytorch/issues/5#issuecomment-439373683, or mute the thread https://github.com/notifications/unsubscribe-auth/AoXVS-9LDS8r4mXopJFIgxhStyXP420Gks5uvqoIgaJpZM4YfsIJ .

Sumes commented 6 years ago

If the images are different it should return non zero value right? I am requesting you to do a unit test kind of thing may be with a notebook or so.

On Sun, Nov 18, 2018 at 10:47 AM Sumesh Uploader sumeshuploader@gmail.com wrote:

Will you please test that with two entirely different images and see what pred is returning?

On Fri, Nov 16, 2018 at 5:35 PM Pin,Fang notifications@github.com wrote:

Please refer to this function: https://github.com/fangpin/siamese-pytorch/blob/c2b1567dc70539f4eddd2935df0c7140309cf20d/mydataset.py#L96 . There is trick to sample test data. I record the target image in self.img1 and always put the image whose class is same as self.img1 into the first position of each mini-batch. So if the model makes a right prediction, the 'pred = np.argmax(output)' should be 0. Hope that will be helpful. @Sumes https://github.com/Sumes

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fangpin/siamese-pytorch/issues/5#issuecomment-439373683, or mute the thread https://github.com/notifications/unsubscribe-auth/AoXVS-9LDS8r4mXopJFIgxhStyXP420Gks5uvqoIgaJpZM4YfsIJ .

Sumes commented 5 years ago

loss_val += loss.data[0] [10] loss: 0.69245 Took 7.14 s [20] loss: 0.68544 Took 1.00 s [30] loss: 0.66013 Took 0.99 s [40] loss: 0.65271 Took 0.99 s [50] loss: 0.63055 Took 1.00 s [60] loss: 0.62372 Took 1.00 s [70] loss: 0.61123 Took 1.00 s [80] loss: 0.61168 Took 1.00 s [90] loss: 0.60554 Took 0.99 s [100] loss: 0.59638 Took 0.99 s Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0

Sumes commented 5 years ago

When I am trying to print the value predicted (pred = np.argmax(output)), with way = , then all the values predicted is 0. So is this correct. please verify and tell. Pasting what i got below. [10] loss: 0.69245 Took 7.14 s [20] loss: 0.68544 Took 1.00 s [30] loss: 0.66013 Took 0.99 s [40] loss: 0.65271 Took 0.99 s [50] loss: 0.63055 Took 1.00 s [60] loss: 0.62372 Took 1.00 s [70] loss: 0.61123 Took 1.00 s [80] loss: 0.61168 Took 1.00 s [90] loss: 0.60554 Took 0.99 s [100] loss: 0.59638 Took 0.99 s Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0 Pred-argmax: 0


[100] right: 100 error: 0 precision: 1.000000