Answers.Body: <p>Traditional CNNs used for image classification (and related tasks) are composed of 1 or more fully connected layers (FCs), after the convolutional and pooling layers, which take as input the features extracted from the convolutional and pooling layers, in order to perform classification or regression.</p>
  <p>One problem with FCs in CNNs is that the number of parameters can be very big, with respect to the number of parameters in the convolutional layers.</p>
  <p>There are tasks, such as <em>image segmentation</em>, where this big number of parameters is not really needed. An example of a neural network that does not make use of fully connected layers but only uses convolutions, downsampling (aka pooling), and upsampling operations is the <a href="https://lmb.informatik.uni-freiburg.de/people/ronneber/u-net/" rel="nofollow noreferrer">U-net</a>, which is used for image segmentation. A neural network that only uses convolutions is known as a <em>fully convolutional network</em> (FCN). <a href="https://ai.stackexchange.com/a/21824/2444">Here</a> I give a detailed description of FCNs and <span class="math-container">$1 \times 1$</span>, which should also answer your question.</p>
  <p>In any case, to answer your question more directly, <span class="math-container">$1 \times 1$</span> convolutions have been used for <strong>image segmentation</strong> tasks, i.e. <em>dense</em> classification tasks, i.e. tasks where you want to assign a label to each pixel (or a group of pixels), as opposed to <em>sparse</em> classification tasks such as image classification (where the goal is to assign 1 label to the whole image). Moreover, in comparison with FC layers, they have <strong>fewer parameters</strong> and, more importantly, the <strong>number of parameters in an FCN does not depend on the dimensions of the images</strong> (as in the case of traditional CNNs), which is a good thing (especially, when your images have high resolutions), but typically it depends on the number of kernels and instances (of objects), in the case of instance segmentation.</p>
  <p><a href="https://arxiv.org/pdf/1411.4038.pdf" rel="nofollow noreferrer">The FCN paper</a> discusses this reduction of the number of parameters (and computation time), so you should probably read this paper for more details.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-23T18:18:01.193Z
Answers.LastActivityDate: 2021-01-23T19:44:31.047Z
Answers.LastEditDate: 2021-01-23T19:44:31.047Z
Answers.UserDisplayName: nbro
Answers.Body: <p>Typically 1x1 convolutions are used for changing the number of channels. Each output channel is a linear combination of the input channels.</p>
  <p>For example, if you perform a 1x1 convolution with only one output channel on an RGB image, then you get a grayscale image, whose intensity is a linear combination of the red, green, and blue values of the corresponding pixel (plus bias).</p>
  <p>If you perform a 1x1 convolution with more than one output channel, then each channel is formed in the same way, as a linear combination of the input channels. You can think of it as multiple convolutions, whose output is stacked on top of each other. All these filters have different parameters.</p>
  <p>Notice that if the output was equivalent to multiplying each channel by a scalar value, then you would always have the same number of inputs and outputs.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-02-09T11:19:32.167Z
Answers.LastActivityDate: 2022-02-09T11:19:32.167Z
Answers.UserDisplayName: Seppo Enarvi
Body: <p>I understand the gist of what convolutional neural networks do and what they are used for, but I still wrestle a bit with how they function on a conceptual level. For example, I get that filters with kernel size greater than 1 are used as feature detectors, and that number of filters is equal to the number of output channels for a convolutional layer, and the number of features being detected scales with the number of filters/channels.</p>
  <p>However, recently, I've been encountering an increasing number of models that employ 1- or 2D convolutions with kernel sizes of 1 or 1x1, and I can't quite grasp why. It feels to me like they defeat the purpose of performing a convolution in the first place.</p>
  <p>What is the advantage of using such layers? Are they not just equivalent to multiplying each channel by a trainable, scalar value?</p>
  
Tags: <convolutional-neural-networks><convolution><filters><convolutional-layers><fully-convolutional-networks>
Title: What is the point of using 1D and 2D convolutions with a kernel size of 1 and 1x1 respectively?
UserDisplayName: Arcturai
ThreadText: # What is the point of using 1D and 2D convolutions with a kernel size of 1 and 1x1 respectively?
  
  (Asked by: username_0 on 2020-04-28)
  
  I understand the gist of what convolutional neural networks do and what they are used for, but I still wrestle a bit with how they function on a conceptual level. For example, I get that filters with kernel size greater than 1 are used as feature detectors, and that number of filters is equal to the number of output channels for a convolutional layer, and the number of features being detected scales with the number of filters/channels.
  
  However, recently, I've been encountering an increasing number of models that employ 1- or 2D convolutions with kernel sizes of 1 or 1x1, and I can't quite grasp why. It feels to me like they defeat the purpose of performing a convolution in the first place.
  
  What is the advantage of using such layers? Are they not just equivalent to multiplying each channel by a trainable, scalar value?
  
  **Tags:** convolutional-neural-networks, convolution, filters, convolutional-layers, fully-convolutional-networks
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2021-01-23. Score: 1
  
  Traditional CNNs used for image classification (and related tasks) are composed of 1 or more fully connected layers (FCs), after the convolutional and pooling layers, which take as input the features extracted from the convolutional and pooling layers, in order to perform classification or regression.
  
  One problem with FCs in CNNs is that the number of parameters can be very big, with respect to the number of parameters in the convolutional layers.
  
  There are tasks, such as *image segmentation*, where this big number of parameters is not really needed. An example of a neural network that does not make use of fully connected layers but only uses convolutions, downsampling (aka pooling), and upsampling operations is the [U-net](https://lmb.informatik.uni-freiburg.de/people/ronneber/u-net/), which is used for image segmentation. A neural network that only uses convolutions is known as a *fully convolutional network* (FCN). [Here](https://ai.stackexchange.com/a/21824/2444) I give a detailed description of FCNs and $1 \times 1$, which should also answer your question.
  
  In any case, to answer your question more directly, $1 \times 1$ convolutions have been used for **image segmentation** tasks, i.e. *dense* classification tasks, i.e. tasks where you want to assign a label to each pixel (or a group of pixels), as opposed to *sparse* classification tasks such as image classification (where the goal is to assign 1 label to the whole image). Moreover, in comparison with FC layers, they have **fewer parameters** and, more importantly, the **number of parameters in an FCN does not depend on the dimensions of the images** (as in the case of traditional CNNs), which is a good thing (especially, when your images have high resolutions), but typically it depends on the number of kernels and instances (of objects), in the case of instance segmentation.
  
  [The FCN paper](https://arxiv.org/pdf/1411.4038.pdf) discusses this reduction of the number of parameters (and computation time), so you should probably read this paper for more details.
  
  
  ---
  
  ### Answer by username_2 on 2022-02-09. Score: 0
  
  Typically 1x1 convolutions are used for changing the number of channels. Each output channel is a linear combination of the input channels.
  
  For example, if you perform a 1x1 convolution with only one output channel on an RGB image, then you get a grayscale image, whose intensity is a linear combination of the red, green, and blue values of the corresponding pixel (plus bias).
  
  If you perform a 1x1 convolution with more than one output channel, then each channel is formed in the same way, as a linear combination of the input channels. You can think of it as multiple convolutions, whose output is stacked on top of each other. All these filters have different parameters.
  
  Notice that if the output was equivalent to multiplying each channel by a scalar value, then you would always have the same number of inputs and outputs.
  
  
  ---
  
  