question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mnist siamese example returning wrong accuracy values

See original GitHub issue

I am executing the mnist siamese example straight away from the keras examples from the version 1.2.0. I am getting an accuracy value of

* Accuracy on training set: 0.42%
* Accuracy on test set: 2.64%

instead of the correct values

Gets to 99.5% test accuracy after 20 epochs.

At first I thought at a wrong image dimension ordering and tryed different configuration for keras.json But the problem persist. After inspecting prediction against the true values I found the vector of prediction is shifted by exactly by one, so I checked for possible code typos with some switch between 1 and 0 in the loss function and in the pair construction, but everything seems ok. I am running the code in a mac book pro with python 2.7 and tensorflow 0.12.1 Anyone who experienced the same issue?

  • Check that you are up-to-date with the master branch of Keras. You can update with: pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps

  • If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.

  • If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with: pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps

  • [] Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:23 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
stale[bot]commented, Sep 21, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.

2reactions
oak-treecommented, Jan 23, 2017

After digging, it looks like @Tokukawa is right. There is a switching problem. According to Dimensionality Reduction by Learning an Invariant Mapping Y=0 if the pair deemd simliar and Y=1 the pair deemed disimilar. image

This is exactly what create_paris does. Moreover, the loss function is reverse indeed. The max between 0 and m-D_w should be the loss for dissimilar pairs and therefore the loss function is also reversed in the terms of y_true

Read more comments on GitHub >

github_iconTop Results From Across the Web

Image similarity estimation using a Siamese Network ... - Keras
We will train the model to differentiate between digits of different classes. For example, digit 0 needs to be differentiated from the rest...
Read more >
Accuracy and error rate of example Siamese network in Keras
So, the accuracy function in the example is implemented such that a fixed arbitrary threshold, i.e. 0.5, is applied on predicted distance values...
Read more >
How To Train Your Siamese Neural Network
This provides an indication of model accuracy when n is the same as the total number of classes, num_classes in the code below....
Read more >
Siamese Network - MNSIT - Breakdown - | notebook.community
Breakdown of network to make sense of components. It was interesting to see the manually constructed loss function; multi input network; shared weights....
Read more >
Contrastive Loss for Siamese Networks with Keras and ...
In this tutorial you will learn about contrastive loss and how it can be used to train more accurate siamese neural networks.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found