1
$\begingroup$

I built a model (InceptionResnet v2) to classify images and I would like to use it to measure similarity between objects.

One way to measure that similarity is to catch an intermediate layer's results from two vector and look their distance.

I don't know how to choose the layer, my last layers are :

Conv -> Flatten(98304,) -> Dense(256,) -> Dense (softmax)

I hesitate between Flatten and first Dense, how to choose ?

$\endgroup$
1
$\begingroup$

For similarity computations, you should generally prefer the last (before softmax) dense layer. This layer will generally capture the most higher level representation of the images. It is also preferable to have the size of vector as small as possible when similarities are to be computed for efficiency reasons.

| improve this answer | |
$\endgroup$
0
$\begingroup$

I recently came across the concept of 'Siamese' network architectures that can serve this purpose. It involves the use of two networks with their parameters linked that are fed pairs of examples as input and learn to approximate a similarity measure.

This 2015 paper has a distance layer in the architecture, maybe give it a read through and see if it is similar to your use case?

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.