CNN, which layer to choose for a similarity measure
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.