30
$\begingroup$

What are "bottlenecks" in the context of neural networks?

This term is mentioned, for example, in this TensorFlow article, which also uses the term "bottleneck values". How does one calculate bottleneck values? How do these values help image classification?

Please explain in simple words.

$\endgroup$

2 Answers 2

39
$\begingroup$

The bottleneck in a neural network is just a layer with fewer neurons than the layer below or above it. Having such a layer encourages the network to compress feature representations (of salient features for the target variable) to best fit in the available space. Improvements to compression occur due to the goal of reducing the cost function, as for all weight updates.

In a CNN (such as Google's Inception network), bottleneck layers are added to reduce the number of feature maps (aka channels) in the network, which, otherwise, tend to increase in each layer. This is achieved by using 1x1 convolutions with fewer output channels than input channels.

You don't usually calculate weights for bottleneck layers directly, the training process handles that, as for all other weights. Selecting a good size for a bottleneck layer is something you have to guess, and then experiment, in order to find network architectures that work well. The goal here is usually finding a network that generalises well to new images, and bottleneck layers help by reducing the number of parameters in the network whilst still allowing it to be deep and represent many feature maps.

$\endgroup$
9
  • 1
    $\begingroup$ Hi @NeilSlater, how is a bottleneck layer different from a bottleneck feature? I have read some kernels on Kaggle and here where people use a pretrained Resnet (after removing its last few layers). The model is made to generate the features without any further training. The features are then passed to a classifier of their choice, usually an SVM or a simpler CNN to learn from those features. Clearly in that case, the network will not learn to compress the feature representations in the available space. $\endgroup$ Commented Jun 2, 2020 at 14:56
  • $\begingroup$ Like here the person uses ResNet kaggle.com/paperboiii/one-class-classification-for-images or here towardsdatascience.com/… $\endgroup$ Commented Jun 2, 2020 at 14:59
  • $\begingroup$ @NeilSlater, How much of a difference does compressing feature representations make to the overall accuracy? $\endgroup$ Commented Jun 2, 2020 at 15:00
  • $\begingroup$ @AnshumanKumar: I suggest you ask a separate question about that on the site. In brief though, a feature vector (or embedding) that is good for one task is often good for a related task without re-training. It might not be as good as if you trained from scratch, but the difference may not be important to you $\endgroup$ Commented Jun 2, 2020 at 15:16
  • $\begingroup$ in order to get the best loss during training. How can a bottleneck layer be useful in getting the best loss during training? $\endgroup$
    – hanugm
    Commented Jan 5, 2022 at 23:38
11
$\begingroup$

Imagine, you want to re-compute the last layer of a pre-trained model :

Input->[Freezed-Layers]->[Last-Layer-To-Re-Compute]->Output

To train [Last-Layer-To-Re-Compute], you need to evaluate outputs of [Freezed-Layers] multiple times for a given input data. In order to save time, you can compute these ouputs only once.

Input#1->[Freezed-Layers]->Bottleneck-Features-Of-Input#1

Then, you store all Bottleneck-Features-Of-Input#i and directly use them to train [Last-Layer-To-Re-Compute].

Explanations from the "cache_bottlenecks" function of the "image_retraining" example :

Because we're likely to read the same image multiple times (if there are no distortions applied during training) it can speed things up a lot if we calculate the bottleneck layer values once for each image during preprocessing, and then just read those cached values repeatedly during training.

$\endgroup$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .