How to tell what a filter may be trying to capture

Can anyone explain how to solve this quiz question?

What do you think applying this filter to a greyscale image will do?

[[0 1 -1 0],
[1 3 -3 -1],
[1 3 -3 -1],
[0 1 -1 0]]

If you are unable to give the solution can you provide the logic for thinking about this question.

Hi @Azfal_Peermohammed ,

First of, I’d like to say that the filters are usually not given to the network, but instead we initialize them and then we let the network to learn them. The initialization of filters in CNNs is a topic in itself.

Now, regarding the specific filter you present, check out these hints:

I would start by looking at things like symmetry of the numbers, the signs of the numbers, and the magnitude.

  • With symmetry (or even anti-symmetry) the filter may be helping detect features.
  • With signs, like 3 followed by -3, the filter can be helping detect borders or edges. In this case, possibly vertical edges.
  • With magnitude the filter can help detect emphasis of features. In this case may be horizontal changes. In this case, the big values are in the center and they tend to diminish towards the edges of the filter. This could help identify contrasts or features.

To fully understand what the filter will do, you can apply it to a greyscale image and examine the results. But based on its structure, it’s likely designed for some kind of edge detection or enhancement along the vertical axis.

I agree. It seems a rather silly question to put in the quiz. It has little to do with any useful machine learning skill. Applying specific filters is more of an image processing method.

Thank you,
I can see how that is verticle edge.

Note that as Juan and Tom have both pointed out, creating “hand-coded” filters like that is not really the way thngs work any more, but Prof Ng does present this concept in the lectures just to give some intuition about how convolutions can actually detect patterns. He devotes a whole lecture early in C4 Week 1 to walking through the example of a vertical edge detector similar to the one in this quiz question to help us see why convolutions are a useful technique. Then we graduate to letting the back propagation learn the filters, once we’re comfortable with the idea. There is a really interesting lecture in Week 4 called “What are Deep ConvNets Learning” where Prof Ng shows some very cool research that instruments the inner layers of a ConvNet so that you can actually see what patterns the filters have learned to detect. So “hold that thought” and stay tuned.