迁移学习中的bottlenecks到底是什么

在学习How to Retrain an Image Classifier for New Categories的时候,在retrain刚开始的时候会建立一堆的bottlenecks文件,所以这到底是用来干什么的呢?

首先,迁移学习只是训练神经网络的最后一层,也就是给出最后结果的softmax层。那我们该如何训练呢?也很简单,每次拿一部分图片喂给神经网络,经过层层网络提取特征后将一个特征向量传递给最后一层,然后最后一层给出分类结果。

上面的方法看起来没什么问题,实际上也没啥问题,就是有点慢。因为我们每次都要计算每张图片的特征向量。而我们知道,在训练过程中同一幅图片会被喂给神经网络很多次,所以我们重复计算了很多次同一图片的特征向量

说到这里可能你就已经明白了:为了避免重复计算每张图片的特征向量,我们把每张图片的特征向量缓存下来,训练的时候复用缓存值来训练最后一层,从而缩短训练时间。

之所以叫bottlenecks,可以看一下下面的解释:

A bottleneck is an informal term we often use for the layer just before the final output layer that actually does the classification. “Bottleneck” is not used to imply that the layer is slowing down the network. We use the term bottleneck because near the output, the representation is much more compact than in the main body of the network.

你可以将bottlenecks看做是神经网络的一层:

//没有bottlenecks的网络结构
loop:
	Input->[Freezed-Layers]->[Last-Layer-To-Re-Compute]

//加入bottlenecks后
Input->[Freezed-Layers]->Bottleneck-Features-Of-Input
loop:
	Bottleneck-Features-Of-Input->[Last-Layer-To-Re-Compute]

参考:

What is the concept of Tensorflow Bottlenecks?

More about Bottlenecks (Optional)

猜你喜欢

转载自blog.csdn.net/guojunxiu/article/details/82708809
今日推荐