What are convolution network layers learning?

In this section, we will explore what the convolution layers are doing while learning. Understanding what activation layers are learning will not only help us to generate art, but will provide us with some useful insight that gives us greater opportunities for improvements.

First, we will see how to visualize the layers' knowledge, using the paper from Zeiler and Fergus 2013, which really does a great job in revealing what the layers are learning. Then we will look at a few examples from the same paper.

Let's look at the VGG-16 architecture, which we have studied previously in Chapter 3Transfer Learning and Deep CNN Architectures, which has several convolution layers followed by fully connected layers and a softmax layer:

To train the model, we have to pick one of the layers, let's consider the second convolutional layer. We will monitor the activation values of 9,000 units or neurons. So, we may choose any of these nine units from the neurons. When the training is complete, we will choose only nine maximum values produced by the nine chosen neurons, together with the image patch that originally caused those neurons to fire maximum values.

So for example, if we have chosen the unit (the dog's nose) as shown in the following diagram, then it may happen that only this part of the image caused that neuron to fire the maximum value:

Whereas for the other neuron, the part of the cat causes the network to fire maximum values:

Next, perhaps the bottom most neuron is more interested in the grass and fires maximum values as shown in the diagram, while the other part of the photo has minimum values:

In short, the part of the image that fires maximum neurons activation values is just visualized. Although this looks simple in a high-level description, the reality is that it's a bit more of a sophisticated method using the convolution layers, and then moving back from the convolution layer to the image.

Let's see some more examples from the table to gain a more consistent idea of what layers are learning as we go deeper into the network.

So, if we visualize the first layer, we can see that the first neuron is interested in diagonal lines as shown in the following diagram:

For the third and the fourth part of the Layer 1, we'll see more vertical lines and horizontal lines detected by the neurons, and the eighth part is kind of obsessed with a green color. It is noticeable that all these are really small parts of the original image, and the layer is catching low-level features.

Let's go to the second layer:

The neurons of this layer start to detect a number of additional features. The sixth and the seventh neurons start capturing round shapes, while the fourteenth one is obsessed with a yellow color.

At the third layer, the neuron starts to detect more interesting stuff. The sixth neuron is more interested in round shapes that look such as tires, the tenth one, it's kind of difficult to say, appears to be more interested in round shapes that are an orange color, while by the eleventh neuron, we see that it is recognizing humans already:

Let's delve a bit deeper at the fourth and fifth layers:

From the preceding diagram, you can see that as we go deeper into the layers, the neurons capture the bigger part of the images, therefore, capturing high-level features of the images, as compared to the low-level layers that capture the smaller part of the image. We can see from the preceding image that the first neuron of the fifth layer is already into dogs, while in the fourth layer we have keyboards, dogs, bicycles, and so on.

Let's summarize our findings. The early layers of a neural network are learning low-level features, such as symbol lines and shapes, whereas when we go deeper, we see that the layers on top are learning more complex features, such as detecting humans, animals, cars, and trees.

In the next section, we will use this intuition and knowledge to generate art from images using neural style transfer.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.12.232