concept filter in category nlp

This is an excerpt from Manning's book Real-World Natural Language Processing.
Then, let’s think of a “filter” of same size (2 circles x 2 circles) that acts as the colored glass we talked about above. Each circle of this filter is also either black or white, corresponding to values -1 and 1. You are going to look at a pattern through this filter and determine if the pattern is the one you are looking for or not. You do this by putting the filter over a pattern and counting the number of color matches between the two. For each one of four positions, you get a score of +1 if the colors match (black-black or white-white) and a score of -1 if they don’t (black-white or white-black). Your final score is the sum of four scores, which varies from -4 (no matches) to +4 (four matches). See figure 7.4 for some examples.
Figure 7.4: Examples of convolutional filters
![]()
The score you get varies depending on the pattern and the filter, but as you see in the figure, the score becomes larger when the filter looks similar to the pattern and becomes smaller when the two are not. You get the largest score (4) when the two match exactly and the smallest score (-4) when the two are exactly opposite. The filter is acting as a pattern detector against the input. Although this is a very simplified example, this is basically what a convolutional layer is doing. In convolutional neural networks, such filters are called kernels.