0

I've built the siamese network from the PyImageSearch.com tutorial here: https://pyimagesearch.com/2020/11/30/siamese-networks-with-keras-tensorflow-and-deep-learning/

I'm augmenting the CNN to detect whether an image is identical (instead of the same number, as in the tutorial). This just calls for augmenting one line of code within the make_pairs() function in utils.py:

old line:       pairImages.append([currentImage, posImage])

new line:       pairImages.append([currentImage, currentImage])

I thought this would be pretty easy for the network to learn 100% accuracy quickly because the images are identical. However, it doesn't achieve accuracy beyond ~95% in 10 epochs.

I think the issue is in the output layer. A euclidean distance is passed to a Dense output layer that contains a sigmoid function. The positive class is identical images, so the euclidean distance between these two images is 0. I'm thinking that if I could change the sigmoid activation from 0.5 to something close to 1.0, it would speed up learning. Identical images would have a euclidean distance of 0, so I imagine this should work.

My question is then:

  1. how do I change the cutoff for the sigmoid function from the default of 0.5
  2. Would changing the sigmoid cutoff have the intended effect?
Timbus Calin
  • 13,809
  • 5
  • 41
  • 59
mjasilver
  • 13
  • 6

1 Answers1

0

Try using rectified linear unit (ReLU) activation instead of sigmoid.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 02 '23 at 13:31