keras-io icon indicating copy to clipboard operation
keras-io copied to clipboard

The example on Siamese Network is not really clear.

Open luigisaetta opened this issue 3 years ago • 4 comments

The example is interesting, but in the last part it is not really clear... and therefore doesn't seem an ... example.

  1. Cosine similarity: It doesn't seem really different that for a 'positive distance the value is : 0.994 and for a "negative example" it is: 0.9918

  2. In the section: explain what the network has learned there is a group of 3x3 images... but then the cosine similarity is computed only for one ... which one the first one?

  3. It is not nice to show that the girl (first row) resembles to a... kind of dog. Since it is on a well-respected site, probably you should be more careful in deciding what to show (and what not...)

luigisaetta avatar Mar 31 '21 03:03 luigisaetta

answer for question 2 : the cosine similarity is computed for the whole batch. question 1 : the model is not performing well at all.

yacinemrabet1 avatar Jan 01 '22 21:01 yacinemrabet1

Agree 100% with OP - not sure what is the value of an "example" that yields absolutely no result (positive and negative have essentially the same value)

wagner-dh avatar Jan 12 '22 18:01 wagner-dh

I agree. And the performance issue is exacerbated by the fact that the sample that is used for evaluation comes from the training set - and the model can still barely tell the difference between a positive and a negative.

As it stands, the code serves more as a blue print for how to use tf.data, applying some transfer learning/fine-tuning to an existing model and implementing a custom loop, rather than a valid example of a functioning Siamese network.

The siamese similarity estimator example on digits may be less shiny, but at least it performs adequatly on proper test samples.

marco-ve avatar Jan 19 '22 09:01 marco-ve

This doesn't seem to work for me either. The dataset is cool, but I don't believe that the positive and negative similarity is valid. doesn't matter what images I put in the cosine similarity is always about the same 0.99

desean1625 avatar Mar 26 '22 01:03 desean1625

Hey all, thanks for the discussion. Please feel free create a pull request for any changes you'd like to see to the example. The process is documented here: https://github.com/keras-team/keras-io#readme

I'll close this issue, but please feel free to continue discussion on one of the channels below:

pcoet avatar Aug 22 '23 03:08 pcoet