concept similarity in category deep learning

This is an excerpt from Manning's book Deep Learning for Vision Systems.
Computer vision intuition: First, we will start with the visual perception intuition and learn the similarities in humans and machine vision systems. We will see how vision systems have two main components: 1) sensing device and 2) interpreting device. Each is tailored to fulfill a specific task.
Note that the similarity between two images would vary depending on the context of choosing the similarity measure. The embedding of an image differs based on the type of the similarity measure chosen. Some examples of similarity measures are color similarity and semantic similarity:

This is an excerpt from Manning's book Deep Learning for Natural Language Processing.
In this code snippet, assume we have an inverted lexicon InverseLexicon, which maps an integer to a word (rather than mapping words to indices). This inverse lexicon restores for the positive indices in the binary-valued input vector featureV a hash value given some hashing function. The value is capped to fall in the range 0…vecSize (with vecSize the desired size of the output vector). In this way, the indexing is performed by the hashing function: similar input values will lead to similar numerical indices being incremented. The amount of similarity is catered for by the specific hash function chosen. Collisions may occur, where different features share the same indices, due to the use of the modulo function:
How to apply Siamese networks for implementing authorship verification. Siamese networks consist of two networks working hand in hand to determine the similarity of two inputs, with a third component judging whether their response to their inputs indicates similarity or not.