Through my study of neural networks, I came across the idea that each layer of a neural network is responsible for recognizing one feature of the input data. For example, if we build a neural network that classifies cars, buses, vans and bicycles, a layer will be responsible to recognize the tires, another one will be responsible to recognize the size of the vehicle. The question is, why is this true? i.e. each layer appears to perform similar to the others and there is no special design for each one. Is there any way to assign each layer a specific feature or it is done implicitly?
-
$\begingroup$ The layers aren't doing that, every neuron is doing the same $\endgroup$– AdityaCommented Jun 5, 2018 at 18:35
-
$\begingroup$ why did you decide that there is some human interpretation of features after each layer? $\endgroup$– AdityaCommented Jun 6, 2018 at 0:49
-
1$\begingroup$ In classification, the goal is to have each neuron at the output layer do that. Interpreting the intermediate layers and neurons is more complicated; see The Building Blocks of Interpretability. Welcome to the site! $\endgroup$– EmreCommented Jun 7, 2018 at 21:16
3 Answers
... each layer of a neural network is responsible for recognizing one feature of the input data. For example, if we build a neural network that classifies cars, buses, vans and bicycles, a layer will be responsible to recognize the tires, another one will responsible for recognizing the size of the vehicle.
There are numerous kinds of neural networks and there are different differentiable components that are used inside them to achieve end-to-end learning. Convolutional layers are responsible for finding the features that are essential for reducing the error. These features are shared among different nodes and are not necessarily meaningful to us. They have to be used simultaneously due to being shared among different weights. What you are trying to say is that in convolutional networks, the first layers attempt to find low-level features like vertical and horizontal edges whilst deeper convolutional layers try to find high-level features which are more abstract. But the point here is that they attempt to recognize and the way they do that is by using weights and activations which are shared in different activation maps. Consequently, one neuron is not necessarily responsible for faces or for cars. There may be different neurons and filters which are responsible for them. Take a look at the link which has illustrated that.
The other point is about fully connected layers which are responsible for classification. What they do is finding decision boundaries to classify inputs or estimating a function for regression tasks. They are not feature extractors in a way convolutional layers do. As it is illustrated in the cited link, what they try to do is to separate the input space to make it possible for generalization in the current feature space.
The question is, why is this true? i.e. each layer appears to perform similar to the others and there is no special design for each one. Is there any way to assign each layer a specific feature or it is done implicitly?
It was not true as mentioned. Although each layer seems similar to other layers, because of the cost function, their corresponding weights are set to decrease the cost function. Consequently, for fully connected layers all the featrues are feed to all the neurons in each layer and the training process decides how to use them. Moreover, the convolutional layers try to find similar patterns, kernels, in the input pattern.
Actually, customary neural networks does not extract features from data. It means that you can not get the outputs of e.g. the second layer and feed them to another machine learning algorithm. If you want to ectract features from your data, you should use auto-encoders (special type of neural nets) but even in auto-encoders, the process of feature extraction is automated and is managed by the model (neural network) itself. So, even with auto-encoders, you can not assign a specific feature to each layer.
First off, a neural network is a black box model and there is no way of really knowing what each layer does in practice. There are examples that have been created that are useful for explaining the conceptual processes that could be happening. The car example and the Eigen-face examples are two that come to mind. In reality, these are carefully tailored examples to help people understand deep learning versus single layer neural nets. My guess is that some intern or grad student serendipitously found the configuration that produced the 'features' for the example. While there are tools that can output the hidden layers, this is not generally done or necessary in practice.
As you note, there is no difference in how the layers function except for which activation function the developer chooses.
What this means in practice is that there are no heuristics that determine the optimal shape or depth of a neural network. Going back to the cars example, from memory, it implies that the model is a three or four layer NN, but you don't know how many nodes are in each hidden layer or the activation function used in each layer.
In reality, the performance of a model might be better with any number of variations in the model, like the number of epochs, number of hidden layers, nodes in each hidden layer, or activation functions at each layer. Defining the model really is more intuition and prototyping than other models (think linear regression). This is where having a good grid search can help.