Roll920 / ThiNet

caffe model of ICCV'17 paper - ThiNet: A Filter Level Pruning Method for Deep Neural Network Compression https://arxiv.org/abs/1707.06342
144 stars 40 forks source link

A question abut the greedy algorithm #6

Closed hezhenjun123 closed 5 years ago

hezhenjun123 commented 6 years ago

hi,it is a so great project.I have a problem about the greedy algorithm in this paper, I think the w*x means the value in the next feature map,is it means we can get the prune filters by computing the sum of the value at the same coordinate in the next feature map from all of the channels?

Roll920 commented 6 years ago

@hezhenjun123 不太明白你的意思,能说的再详细一些吗,具体是指文章中哪一步,哪一条公式?

hezhenjun123 commented 6 years ago

@Roll920,不好意思,英文实在太烂了,回过头才知道是国人大大~主要是在公式6的实现上吧,我想在下个输出特征图上求得,感觉在当前输入特征和卷积核上求有点绕~想着是不是可以通过求下一个特征层上同一个位置上不同通道之和会等于那个x(i,j),刚看了下貌似不太对

Roll920 commented 6 years ago

@hezhenjun123 没事没事,多思考交流一下,总会有新的收获的。我们的出发点是剪除layer i的几个filter,使得下一层的输出误差最小(layer i+2的input),所以这里关注的是layer i+1的input,weights,output。目前也有工作关注于最终的loss,即剪除使得loss损失最小的filter。如果您有更好的idea,可以尝试形式化地描述它,然后通过实验来验证,祝您工作愉快!

hezhenjun123 commented 6 years ago

@Roll920非常感谢你的回复,整个流程是不是就是,为了去除layer i中几个影响因子不大的filters,又为了保证layer(i+2)的input损失足够小,利用这个贪心算法对layer(i+1)的卷积核进行通道删减,从而达到对layer i 的卷积核进行删除的目的。不知道这么理解是不是对的……

Roll920 commented 6 years ago

@hezhenjun123 是这个样子的。整个流程如图1所示,由于剪枝操作只影响layer i的filter个数和layer i+1的channel个数(图中标虚线的部分),并不影响layer i+2的输入的形状,所以可以通过最小化其重构误差来达到选择的目的。

hezhenjun123 commented 6 years ago

@Roll920非常感谢,茅塞顿开啊,可能以后还会有些问题讨教,希望大神不吝赐教~祝工作顺利,天天开心

Roll920 commented 6 years ago

@hezhenjun123 客气客气,也祝您工作顺利~

hezhenjun123 commented 6 years ago

@Roll920,你好,在公式5里面我发现那个求和得到的特征元素块(就是那个y值)是在layer(i+2)特征图里面随机选取得到的,为什么不求出所有layer(i+1)同一通道和卷积核layer i 的所有乘积,然后对他们的和值进行排序,再删掉那些和值小的通道呢?感觉随机选取元素块可能不能代表所有卷积核的表达。。。不知道我这么想有什么问题?

Roll920 commented 6 years ago

@hezhenjun123 如果我没理解错的话,您的意思是不是说选取所有位置点,而不是随机采样?关于随机采样的原因是这样的:对于VGG16而言,conv5_3的输出是14x14x512=10^5,ImageNet中有128W=10^6张图,因此一共有10^11个locations,这样大的数据量全部采样是不太现实的。而且我们在实验中发现,增大采样的数据量并不能显著增加最终的性能,因此选定了目前的设置。

hezhenjun123 commented 6 years ago

@Roll920,是这个意思。。。当初也是怀疑这个随机选取点可能不能代表整个特征层的值的分部规律。确实如果全部考虑计算量会提高很多。从原理上是不是可以这么认为,特征输入对于所有的通道卷积都是一致的,所以决定输出特征各个通道的数值分布关键是由卷积核通道里面的值的分布决定,所以大体上特征图的元素的块与块之间的通道的数值分布是相似的。。。。也是感觉上,没太多理论依据。。。不过还是觉得很神奇

Roll920 commented 6 years ago

@hezhenjun123 不妨可以这么认为