5
$\begingroup$

I know they are not the same in working, but an input layer sends the input to $n$ neurons with a set of weights, based on these weights and the activation layer, it produces an output that can be fed to the next layer.

Aren't the filters the same, in the way that they convert an "image" to a new "image" based on the weights that are in that filter? And that the next layer uses this new "image"?

$\endgroup$
3
$\begingroup$

tl;dr The equivalent to a neuron in a Fully-Connected (FC) layer is the kernel (or filter) of a Convolution layer

Differences

The neurons of these two types of layers have two key differences. These are that the convolution layers implement:

  • Sparse connectivity, i.e. each neuron is connected only to an area of the input, not the whole.
  • Weight sharing, i.e. similar connections end up having the same weights. This is usually visualized as the same filter traversing the image.

Besides these two key differences, there are some other technical details, e.g. how the biases are implemented. Other than that they perform the same operation.

What causes some confusion is that the input of a CNN is usually 2 or 3-dimensional, while a FC is usually 1-dimensional. These aren't mandatory however. To better help visualize the differences between the two I made a couple of figures illustrating the differences between a conv-layer and a FC one, both in 1D.

Sparse connectivity

On the left are two FC neural networks. On the right, are layers with sparse connections.

Weight sharing

On the left is a sparsely connected network. The colors represent the different values of the weights. On the right is the same network with weight-sharing. Note that similar weights (i.e. arrows with the same direction in each layer) have the same value.


To answer your other questions:

Are filters not the same in the way that they convert an "image" to a new "image" based on the weights that are in that filter? And that the next layers use these new "images"?

Yes, if the input of a convolution layer is an image, so will the output. The next layer will also operate on an image.

However, I'd like to note that not all convolution layers accept images as their inputs. There are 1D and 3D convolutional layers as well.

$\endgroup$
0
0
$\begingroup$

The other answer gives a good overview of the differences between MLPs and CNNs, and it includes 2 diagrams that attempt to illustrate the main differences between MLPs and CNNs, i.e. sparse connectivity and weight sharing. However, these diagrams do not clarify what a neuron in a CNN could be. A better diagram, which illustrates what a neuron is in a CNN, from a CNN and MLP perspective, is the following (taken from the famous article on CNNs).

enter image description here

Here, there are 2 main blocks (aka volumes): the orange block on the left (the input) and the blue/cyan volume on the right (the feature maps, i.e. the outputs of the convolutional layer, i.e. after the application of the convolutions with different kernels).

The circles in the visible stack of the cyan block represent the neurons (or, more precisely, their activations or outputs). We only see $k=5$ neurons stacked: this corresponds to the application of $k=5$ different kernels (i.e. weights) to that specific subset of the input (aka receptive field), hence the sparse connectivity of CNNs. So, these neurons, in the same stack, are looking at the same small subset of the input, but with different weights (i.e. kernels). The neurons, which are not shown in this diagram, that are on the same (vertical) 2d plane (known as feature map) of the same neuron (e.g. the first that we see from left to right) in the cyan volume are the neurons that share the same weights, i.e. we use the same kernel to produce their outputs.

So, in this biological/neuroscientific view of the CNN, when you apply the convolution (or cross-correlation) operation with 1 specific filter (or kernel), you are computing the activation (not to be confused with the activation function, which is used to compute the activation!) i.e. the output of multiple neurons, all of them share the same weights. You stack all these activations on the same 2d plane (known as feature map) of the output volume: note that this operation is just the convolution operation! When you compute the convolution with another kernel, you are again computing the activation of other multiple neurons, which share another different weight matrix, and so on and so forth.

Some authors prefer to use the term convolutional networks, i.e. without the term neural, probably because of this issue, i.e. it's not clear, especially to newcomers, what a neuron would be in a CNN, so the neuroscientific/biological view of CNNs is not always clear, although it's important to emphasize that CNNs were inspired by the visual cortext, so this biological interpretation could (and should) be more widely known or less confusing/misunderstood.

Now, let's address your question more directly.

Aren't the filters the same, in the way that they convert an "image" to a new "image" based on the weights that are in that filter? And that the next layer uses this new "image"?

The filters in a CNN correspond to the weights of an MLP.

A neuron in a CNN can be viewed as performing exactly the same operation as a neuron in an MLP. The big differences between a CNN and an MLP (as explained also in the other answer) are

  • Weight sharing: Some neurons (not all!) in the same convolutional layer share the same weights. The convolution (or cross-correlation) is the operation that implements this partial forward pass with the same weights for different neurons.

  • Neurons in a CNN only look at a subset of the input and not all inputs (i.e. receptive field), which leads to some notion of sparse connectivity

  • A convolutional layer, in a CNN, is composed of neurons in a 3d dimensional volume (or, more precisely, their activations are organized in a 3d volume), rather than a 1-dimensional one, as in an MLP.

  • CNNs may use subsampling (aka pooling)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.