The difference between full connection, local connection, full convolution and local convolution

insert image description here

1. Fully connected

Fully Connected, also known as Dense Connection, is a basic connection method in neural networks. In a fully connected layer, each neuron is connected to all neurons in the previous layer to form a fully connected structure. Fully connected layers are usually used to map the features of the previous layer to the final output category or value.

insert image description here

The characteristics of the fully connected layer include:

  1. Number of parameters: The number of parameters in the fully connected layer is related to the number of neurons in the previous layer and the number of neurons in the current layer, and there are many parameters.
  2. Feature combination: The fully connected layer can combine the features of the previous layer into a higher-level feature representation through weight learning.
  3. Flexibility: Fully connected layers can be used in various types of neural networks, such as feedforward neural networks, deep neural networks, etc.
  4. Final mapping: In classification problems, a fully connected layer is usually used for the output layer, which maps the previous features to the scores of each category.

However, there are also some problems with the fully connected layer:

  1. Too many parameters: A large number of fully connected layers will lead to an increase in the number of parameters of the model, increasing the risk of overfitting.
  2. Computational complexity: More parameters will lead to increased computational complexity, which is not conducive to the efficiency of training and reasoning.
  3. Location information: The fully connected layer does not retain the input location information, which is less applicable to tasks that need to preserve the spatial structure, such as image segmentation.

In order to solve the problem of the fully connected layer, some new network structures, such as convolutional neural network (CNN) and attention mechanism, introduce concepts such as local connection and weight sharing, so as to better deal with images, sequences, etc. sexual data.

2. Local connection

Locally Connected is a neural network connection method. Compared with full connection, local connection connects input neurons to output neurons in certain areas, thus considering the local feature relationship of input data. This type of connection is usually more suitable when dealing with data with local structure, such as image data.

insert image description here

Features of local connections include:

  1. Parameter sharing: In local connections, different output neurons at the same location share the same weight parameters. This sharing can reduce the number of parameters and reduce model complexity.
  2. Local features: Local connections can capture the local features of the input data and help to extract features related to the spatial location of the input data.
  3. Computational efficiency: due to parameter sharing, local connection can reduce the amount of calculation and is suitable for processing large-scale image data.

An example of local connections can be found in Convolutional Neural Networks (CNN). In the convolution layer of CNN, the convolution kernel performs convolution operation on the input data through the sliding window, and the neurons in each window share the weight parameters of the convolution kernel. In this way, convolution operations can share the same parameters on different input regions, thereby capturing the local features of the input data.

Although local connections are very effective in dealing with local features, for some tasks, such as sequence data processing (such as natural language processing), full connections or other connection methods may be more suitable. Therefore, according to task requirements and data structure, different connection methods can be selected to build neural networks.

3. Full convolution

Fully Convolutional (Fully Convolutional) is a convolutional neural network (CNN) structure. Its main feature is to replace the traditional fully connected layer with a convolutional layer, so that the network can accept input of any size and output features of the corresponding size. Graph, suitable for pixel-level tasks such as image segmentation and semantic segmentation.

The main application of full convolution is to process an input image and output a pixel-level label prediction, such as segmenting the input image into different objects or categories. This is different from the traditional CNN structure, which usually performs feature extraction in the first few layers, and then classifies through the fully connected layer, which cannot accept input images of different sizes.

Features and advantages of fully convolutional networks include:

  1. Spatial information preservation: The fully convolutional network can preserve the spatial information of the input image, allowing the model to predict at the pixel level, and is suitable for tasks that require fine spatial segmentation.
  2. Adapt to different sizes: The fully convolutional network can accept input images of different sizes, because the convolution operation has translation invariance and is suitable for processing multi-scale images.
  3. Effective parameter sharing: The convolution operation of the fully convolutional network can realize parameter sharing, reduce the number of model parameters, and improve training efficiency.
  4. Pixel-level prediction: The output of the fully convolutional network is a feature map, and each pixel corresponds to the corresponding class or label prediction.

A classic fully convolutional network is U-Net, which is used for medical image segmentation. The U-Net structure consists of an encoder and a decoder, the encoder is used to extract features step by step, and the decoder is used to restore the feature map to pixel-level prediction. Fully convolutional networks have achieved remarkable results in tasks such as image segmentation and object detection, and have become an important architecture in deep learning.

4. Local convolution

Locally Convolutional (Locally Convolutional) is a convolution operation. As opposed to the full convolution operation, the local convolution applies a convolution kernel in a local area of ​​the input data to capture local features. This convolution operation can extract local features more efficiently in some image processing tasks, such as object detection, edge detection, etc.

Features of local convolution include:

  1. Local feature capture: By applying a convolution kernel in a local area of ​​the input data, local convolution can capture local features of the image, such as edges, textures, etc.
  2. Parameter sharing: Similar to full convolution, local convolution can also achieve parameter sharing, reducing the number of parameters and improving the efficiency of the model.
  3. Computational efficiency: Since the convolution operation is only performed in a local area, local convolution can reduce the amount of calculation and is suitable for processing large-scale image data.

Local convolution has been applied in some specific convolutional neural networks, such as the YOLO (You Only Look Once) target detection model. In YOLO, local convolution is used to capture the position and boundary information of objects, so as to realize real-time target detection.

It should be noted that local convolution is not an independent convolution operation, but a convolution method applied in a specific situation. In some tasks, local convolution can better capture the local structural information of the image, thereby improving the performance of the model.

Five, the difference

Fully Connected, Locally Connected, Fully Convolutional, and Locally Convolutional are common connection and convolution methods in neural networks. They are briefly distinguished below:

  1. Fully Connected:

    • Fully connected layer is one of the most common neural network layers, also known as densely connected layer or fully connected layer.
    • In a fully connected layer, each neuron is connected to all neurons in the previous layer.
    • The fully connected layer is often used in the output layer of a deep neural network to map the features of the previous layer to the final output category or value.
  2. Locally Connected:

    • A locally connected layer is a layer that connects input neurons to output neurons within certain regions.
    • This connection method can consider local feature relationships instead of global connections when processing data such as images.
    • The local connection layer can reduce the number of parameters and improve computational efficiency, and is suitable for some tasks with local relevance.
  3. Fully Convolutional:

    • Fully convolutional networks are often used for tasks such as image segmentation and semantic segmentation.
    • Full convolution refers to replacing the traditional fully connected layer with a convolutional layer, so that the network can accept input of any size.
    • This design allows the network to generate pixel-level output, suitable for tasks where a label needs to be predicted for each pixel in the image.
  4. Locally Convolutional:

    • Local convolution means that the convolution kernel only slides in the local area of ​​the input data for convolution operation.
    • This convolution method can reduce the amount of calculation and is suitable for processing large-scale image data.

In general, full connection and local connection describe the connection between neurons, while full convolution and local convolution describe the way the convolution kernel slides on the input data. These different connection and convolution methods can be flexibly selected according to the requirements of the task and the characteristics of the data to optimize the performance and efficiency of the model.

Guess you like

Origin blog.csdn.net/m0_47256162/article/details/132175074