ETALON IMAGES : UNDERSTANDING THE CONVOLUTION NEURAL NETWORKS

In this paper we propose a new technic called etalons, which allows us to interpret the way how convolution network makes its predictions. This mechanism is very similar to voting among different experts. Thereby CNN could be interpreted as a variety of experts, but it acts not like a sum or product of them, but rather represent a complicated hierarchy. We implement algorithm for etalon acquisition based on well-known properties of affine maps. We show that neural net has two high-level mechanisms of voting: first, based on attention to input image regions, specific to current input, and second, based on ignoring specific input regions. We also make an assumption that there is a connection between complexity of the underlying data manifold and the number of etalon images and their quality.


INTRODUCTION
For the last past years in computer vision society there were introduced tremendous variety of different neural networks architectures (Redmon et al., 2016), (Girshick, 2015), (He et al., 2016).There are different ideas behind these nets, which are explained by intuition and a good guess rather than strict theory, but the core blocks all of them are the samethey all utilize convolution and pooling layers.Such first CNNs as AlexNet and VGG, using only simple convolutions and pooling blocks without any additional connections (that exist in ResNet and DenseNet), haven't shown such good quality, compared to the modern CNN architectures.But they have demonstrated the ability to fit data and to outperform previous state of the art algorithms.Given this, it is rather obvious that a good start point for deep neural network understanding is the first, simple CNNs.
To analyze CNN behavior, we select MNIST challenge and one of the common nets with good results on it (LeNet (LeCun et al., 1988), but we use its slight modification, replacing sigmoid activation units with ReLU).This net has simple consecutive convolution and pooling layers with ReLU activation functions.It also has 10 output neurons for final predictions (each neuron predicts class specific probability for input digit).The schematic network's figure present in Fig. 1.
For explaining the notion of etalon it's useful to consider CNN from functional point of view.According this interpretation CNN represent parametric family of functions which depends on net architecture and neuron's activation functions.During training network parameters are tuned and as a result we get one instance form this family.For our particular network with ReLU activations if we don't take into account the last SoftMax layer, then whole network represents the piecewise linear function in high dimensional input space.Each input image lies in some flat region where network behaves like affine transformation.This means that there is small neighborhood around any input image where CNN behaves like an affine transformation.Its size and topology depend on the complexity and form of the data manifold.As known CNN gives effective implicit representation of this manifold and etalons give way to look at it.

RELATED WORKS
For now, deep learning methods, especially based on deep neural networks, play an important role in information processing of visual data.At the heart of these models lies a hypothesis, that deep models can be exponentially more efficient at representing some functions than their shallow counterparts (Bengio, 2009).
There is no strong theoretical justification, but there is a lot of practical experiments and promising results.It based on assumption that higher layers in a deep model can use features, constructed by the previous layers in order to build more complex functions and not to learn low level features again.For example, in CNNs for image classification (object detections and other vision tasks), first layer can learn Gabor filters that are capable to detect edges of different orientation.These edges are then put together at the second layer to form part-of-object shapes.On higher layers, these part-of-object shapes are combined further to obtain detectors for more complex part-of-object shapes or objects.Such a behavior is empirically illustrated, for instance, in (Zeiler and Fergus, 2013), (Lee et al. 2009).On the other hand, a shallow model has to construct detectors of target objects based only on the detectors learnt by the first layer.
There are also some theoretical justifications which prove the possibility for Deep Neural Nets to reconstruct functions with exponential number of regions.One example of such work is (Montufar et al., 2014).In this work authors investigate deep feed forward neural net with piecewise linear activation units.The intermediary layers of these models are able to map several pieces of their inputs into the same output.The layer-wise composition of the functions computed in this way re-uses lowlevel computations exponentially often as the number of layers increases.As a result, deep networks are able to identify an exponential number of input neighborhoods by mapping them to a common output of some intermediary hidden layer.The computations of the activations of this intermediary layer are replicated many times, once in each of the identified neighborhoods.This allows the networks to compute very complex looking functions even when they are defined with relatively few parameters.There are also some works dedicated to understanding how neural networks perceive images.
One well known method, described in work (Zeiler and Fergus, 2013), shows the way of getting regions in input image which are responsible for activation one or other neuron.In our work we try to investigate the other side of the problem.We concentrate on the mechanism which neural net obtains during training to perform its tasks (in this work we consider the classification task).We don't consider the problem of representation capability, however we suppose that there is a connection between complexity of the underlying data manifold and the number of etalon images and their quality.We guess that analyzing etalons can give some insight into problem of under and overfitting and models comparison based on last ones.Our work is similar to work (Zeiler and Fergus, 2013) in sense of visualization of regions, which neural network concentrates on.
However, etalon images aren't regions in input image.They are affine maps, defined on the input space and represents the behavior of the network on particular image.

Image etalon definition
As was mentioned above, we consider CNN without last SoftMax layer.The output of such net is 10-dimensional vector with unnormalized class scores (one for each digit class).Let  be any input examplea vector of size  (for our consideration we flatten it's dimensions but one can take in mind that it is a grayscale picture with spatial sizes), the function, represented by CNN that we describe earlier.According to introduction part, if we use ReLU as an activation function, for activated neurons we can write network transformation for vector  as: where   = affine transformation specific to     = transformation matrix of the      = bias of the   * = matrix product This transformation take place between input space of images (m-dimensional) and output 10 dimensional space (class specific unnormalized scores), so    is a 10 ×  matrix.Next we emphasize very simple fact which is important for further study: if we consider the whole net as an affine transformation, then we can treat any neuron as an affine map from input space to the real line ℝ.We show this for the output neuron from the last layer, but, as we will see further, this is also valid for all other neurons in any layer.
Let us look at one neuron  from the 10 output neurons and denote its output as ()  .For this neuron we can do all the steps above and write its affine map: where (  )  = transformation matrix specific to neuron p (  )  = bias term specific to neuron p like in (1) 〈⋅〉 = scalar product.
For output neurons there is obvious relationship between matrixes and biases terms in equations ( 2) and (1).It is easy to see that (  )  is just row  in matrix    and also (  )  is p-th component in vector    .Then we can write: As was mentioned above such affine function could be defined for any neuron in CNN.
We call (  )  an etalon image for the input image  and the neuron , because it has the same dimensions as the input vector .The work of the whole CNN can be presented as the scalar product between the image and its etalon.Despite the fact that each neuron has its own etalon for every image, effective number of etalons depends on the data manifold complexity and also on the training algorithm and network architecture.But if we suppose that network architecture isn't too overabundant and train procedure is affective then first factor is dominant.Consequently, for more complicated dataset we shall have more etalons, and CNNs should have capacity to keep all of them, and that is exactly what they are good at, according to many practical and some theoretical results (Montufar, 2014).In the next paragraph we'll give you more constructive view on etalons and it would be clear that CNN can keep the large number of them.That's why etalons are another argument why CNN outperforms previous methods.

Etalon subgraph
In this paper we develop a method for getting the etalon from an input image.This method is based on another etalon interpretation like a subgraph in CNN.We can consider a neural net as graph, where neurons are vertexes and interlayer connections are edges.When a new image is passed to the network input, it goes successively through all layers.One can interpret this as some kind of flow, spreading through the network graph.But in contrast to classical flow, where there are sources and stokes, we don't have stokes here, however this interpretation is helpful.There is also one important point, connected with ReLU activations: the flow spreads through only some subgraph with non-zero activations.When ReLU gives us zero activation, it does not affect all further calculations, so we can freeze edges between this neuron and successive layer.Summarizing all the above, each etalon can be associated with its own subgraph.
For better understanding how it works, let us consider the following example.Net structure is shown in the picture below (Fig. 2).For simplicity we consider an example with twodimensional input and two fully connected layers (activation functions are ReLU).
) is passed as an input to the CNN.We marked in red connections, that are active for a current input.One can see that connections with Y 2 are inactive, because Y 2 = 0 (ReLU(⋅) = 0) and does not affect the final outcome.
Let us take the vector  = ( 1 ,  2 ) as an input and calculate the network output on it.Suppose that activation  2 argument is less than 0, so  2 = ReLU(⋅) = 0 and does not affect the result.We also assume that  2 argument is also less than 0. Then we have: As a result we get the explicit view of the  1 neuron affine map for the given input, according to equation (2).One can see the relation between affine map and subgraph, which is obtained as a result of the input vector passing through the network.This graph only includes those neurons, that have non-zero activations and its highlighted with red connections in Fig. 2. It is rather obvious that all the results are valid for CNN because they are just specific type of fully connected networks with most of the connections equal to zero.We can conclude that one possible way of getting neuron etalons is through reconstructing the graph of its affine map.In next section we describe how to do this.

Etalon acquisition
The above results prove that if subgraph and input vector are known, then it is possible to reconstruct the etalon image.However, in arbitrary CNN it is rather difficult to get separate components of an etalon image altogether simultaneously.But it is possible to get these components separately.We know that network processes any image as scalar product between its etalon and image itself plus bias term.Using linearity of the scalar product, we can write down next statement for the input image  and any neuron : where   = the basis coordinate vector (coordinate image) with component , equal to 1, having all other components equal to 0, (  )  = ( 1 ,  2 , … ,   )  is the etalon image for the neuron  of the input image (we flatten etalon as input image).From ( 6) we can conclude that if we feed coordinate vector   as input, then we get component   of the etalon vector (  )  .However we note that simply feeding this vector does not make sense because there is no guaranty that etalon subgraphs for image  and coordinate image   are coincide.But if we freeze all connections in the network except those, which belong to subgraph of the (  )  etalon and pass   through the network, we get reliable result.
It is obvious that for freezing we need to know etalon subgraph for image .In principle it is not a problem, because we can track active connections in layers to form our graph structure and know the graph, then perform calculations for each coordinate image   using simple traverse of the graph.However, we decided to go the other way and freeze unused connections (those where ReLU equals to zero) on the flight.It is very easywe can set activations of one particular neuron to zero to freeze its connections.Then they will not affect further computations, and it is equivalent to removing these connections.

Etalon reconstruction algorithm
In this section we propose an algorithm for etalon reconstruction, which outputs etalon image (  )  for the input image  and the neuron .You can see the algorithm 1 steps in Fig. 3


In step 2 we nullify all biases in the network, because they influence the neuron activations and, as a result, we'll get incorrect values for components of the (  )  (which would be equal to the sum of -th component and bias term).However, from equations ( 2), ( 5) we see that affine transformation has two independent partsone for linear transformation and other for translation (bias term).Consequently, we can zero biases for reconstruction etalon image. In step 3.1 we pass each coordinate image and according to our implementation of ReLU and Pooling layers they flow through required subgraph. In step 3.2 we take activation of the given neuron  which equals to -th component of the etalon image For better insight we visualize the work of algorithm 1 on a simple example of etalon reconstruction for  1 neuron.We also assume that  2 argument is also less than 0. For simplicity the net from Fig 2 .was taken again, and the same proposals are suggested: it is a simple fully connected net with two layers and two-dimensional input  = ( 1 ,  2 ).Suppose that activation  2 argument is less than 0, so  2 = ReLU(⋅) = 0 and does not affect the result.According to step 1 input image  = ( 1 ,  2 ) is passed to the net, and we remember non-zero activations (see Fig. 4). .vector X = (X 1 , X 2 ) is passed as an input to the CNN.We marked in red connections, that are active for a current input.Since neurons  2 ,  2 activations are zero, their connections are freezed.
Summarizing equations ( 9) and ( 10 In this algorithm we don't reconstruct bias term in (2), however it is straightforward to do.Between steps 1 and 2 in algorithm 1 we can feed zero vector to the net, which gives us bias as activation value of the neuron .Indeed, according to system (4), if vector (0,0) is passed to the net, we have: Comparing ( 5) and ( 11), we see neuron  1 activation contains bias term of the (  )  1 etalon image affine map.But for etalon images this doesn't make sense, so we ignore this step. .feeding the second coordinate vector (0,1) to get the second component of the etalon (  )  1 .Components that were frizzed during step 1 of the algorithm 1 aren't shown.

Etalon reconstruction algorithm limitations
This algorithm is time consumingfor LeNet network with input image's resolution  ×  we need to make  2 forward passes.
Cutting subgraph from network and performing calculations with it can reduce computation cost because of reducing the number of active connections, but neural nets use effective implementation of their operations in CUDA.In addition, we also need perform  2 forward passes.One possible solution is try to reconstruct etalon for one forward pass.It could be done by noting that convolution operation could be represented as linear mapping.ReLU activations after each mapping just nullifies some rows of transformation matrix of that mapping (concrete rows depends on input image).As a result, we can consider network as a product of affine mapping (different for each image).Multiplying all affine transformation, we'll get another one which rows represent etalon images.However, representing convolution operation as matrix product requires a lot of memory.We didn't investigate this way in practice.

LeNet etalon reconstruction
As was mentioned above, we choose LeNet for our experiments.
We experimented with different images and show our results in Fig. 11.For experiments we concentrate on penultimate layer and visualize etalons for each neuron from this layer for different input images.As a result, for each image there are ten etalon images (one per each neuron).For better interpretation we consider several examples.
From example 1 we can see, that neural net tries to give attention to definite regions of input image and does it depending on the input.In the next example we show another mechanism, which is reversed to mentioned above.
In example 2 we demonstrate another mechanism, different from example 1.Here, our net is strongly sure that particular image doesn't belong to given class, it simply votes against it, and again we see that it concentrates its attention on concrete regions.
Example 1: Input image class -0 (Fig. 7.) Figure 7 For this image here we visualize etalon images from several neurons (Fig. 8) image 0 6 2 5 Figure 8. Etalon images for neurons 0, 2, 5, 6 Numbers in captions are neurons, responsible for corresponding image class.White spots in etalon images can be interpreted as most important regions in input image on which neural net concentrates its attention.And, vice versa, black spots are regions which net prefers to ignore.We highlighted with red those regions that neural net makes attention on.From neuron 0 etalon image one can conclude that net tries to concentrate its attention on places which are responsible for zero number.Also it should be emphasized that it is not a simple tracking of most possible regions, but it is specific for concrete input picture.There are many possible zeros in train set which are located near boundaries, but net puts some weights on positions, that are specific to concrete image.From the other hand, if we look at neuron etalon 5 image, then one can conclude that the net has some imagination.From this picture we can see how our net tries to propose possible look of number 5 in this image.We see that it tries to use bottom part of zero number in the picture to draw number five.On neurons 2 and 6 we see similar behavior.However, when this etalons images multiplied with input one it is easy to see, that biggest response is for zero etalon image.
We highlighted with red those regions which neural net tries to ignore.From neuron zero etalon image you can see, that net votes against this class.It puts very low weights on places where number four is located and, as a result, this class has very small score.The same situation we can see for etalon image of neuron one when number six is processedneural net is completely sure that this picture can't below to class one, so it votes against it.

CONCLUSIONS
In this work we represent a new notionetalon images, which are defined as affine maps for any neuron and given input image.
From the construction point of view etalons can be considered as subgraphs in the whole neural network graph.We implement algorithm for their acquisition based on well-known properties of the affine maps.Their analyses have shown that neural net has two high-level mechanisms of voting: first, based on attention to the input image regions and specific to current input, and second, based on ignoring specific input regions.We also suppose that there is a connection between complexity of the underlying data manifold and the number of etalon images and their quality.We guess that analyzing etalons can give some insight into problem of under and overfitting and models comparison.We concentrate on these problems in our future works.

Figure 1 .
Figure 1.Schematic view of LeNet.We exclude SoftMax layer from further consideration Figure4.vector X = (X 1 , X 2 ) is passed as an input to the CNN.We marked in red connections, that are active for a current input.Since neurons  2 ,  2 activations are zero, their connections are freezed.

Figure 5 .
Figure 5. Feeding the first coordinate vector (1,0) to get the first component of the etalon (  )  1 .Components that were frizzed during step 1 of the algorithm 1 aren't shown.

Figure 11 .
Figure 11.First column contains ten input images of the different classes from MNIST dataset.Rows from 1 to 10 contains their etalon images, row  contains etalon image of the corresponding neuron (each neuron has its own class for which it is responsible for).For example, neuron 8 for digit 8 has very clear etalon -one can see specific cross-figure of the digit 8.