he-y / soft-filter-pruning

Soft Filter Pruning for Accelerating Deep Convolutional Neural Networks
https://arxiv.org/abs/1808.06866
374 stars 74 forks source link

how to obtain the pruned new model? #2

Closed lith0613 closed 5 years ago

lith0613 commented 5 years ago

The code just use a mask to replace the pruned filters, but how to get the real pruned model ? Besides, can your share your method about how to calculate the flops of your work ?

he-y commented 5 years ago

you could refer to the code to get the detailed structure of the pruned model. I will check and update the conversion code as soon as possible.

Assume the identity mapping of one block is "conv(x) + iden(x)". As shown in the setting of section 4.3, "We do not prune the projection shortcuts for simplification." Therefore, the output channel of "conv" is reduced, while the output channel of "iden" is the same as the original. To conduct the adding correctly, you should be careful about the index.

Assume the original channel dimension is 64, and pruning rate is 0.5. The index of 32 conv(x) and 32 iden(x) may be not the same index, which is assumed [0,2,4...,62] and [1,3,5...,63]. To add them, what you should do is to build a tensor with the dimension [out_channel,in_channel,H,W]=[32,64,3,3] instead of [32,32,3,3], so every information channel could be kept. Therefore, flop reduction rate = pruning rate for the first layer of block, while flop reduction rate = (pruning rate)^2 for other layers.

lith0613 commented 5 years ago

I see the code of imagenet_resnet_small, but these functions are not called in other files. I don't know what is meaning of the parameters in these functions. Can you make a explanation about them? Thank you !

he-y commented 5 years ago

Please refer to the released pruned model and instruction for the model. You can find the construction of pruned model here.

Ariel-JUAN commented 5 years ago

@he-y Hi, will you release getting the real pruned model codes?

lith0613 commented 5 years ago

Please refer to the released pruned model and instruction for the model. You can find the construction of pruned model here.

hi, He, I am sorry to bother you again. I still haven't got the details about how to use your zero-model to obtain the without-zero model. Although I found and tested your released compact ResNet-50 model. But I want to know the details about how to use your zero-model to get the without-zero model, for other model such as ResNet-34. Can you give a example code. I don't know how to use your small model code, because these functions are not called in other files.

he-y commented 5 years ago

Hi, sorry for the delay code release. Please refer to the conversion code here. The corresponding explanation is here.

lith0613 commented 5 years ago

Hi, sorry for the delay code release. Please refer to the conversion code here. The corresponding explanation is here.

Thanks so much ! I test the code, but the script run error in ResNet34 and ResNet18, looking forward to your update !

TheLostIn commented 4 years ago

Hi, sorry for the delay code release. Please refer to the conversion code here. The corresponding explanation is here.

Thanks so much ! I test the code, but the script run error in ResNet34 and ResNet18, looking forward to your update !

Hi,I test ResNet18,failed too, I also want to know what the use of 5 in line 282 for x in range(0, len(item) - 2, 5). Have you solved it?

xuzhuang1996 commented 2 years ago

Hi, sorry for the delay code release. Please refer to the conversion code here. The corresponding explanation is here.

Thanks so much ! I test the code, but the script run error in ResNet34 and ResNet18, looking forward to your update !

Hi,I test ResNet18,failed too, I also want to know what the use of 5 in line 282 for x in range(0, len(item) - 2, 5). Have you solved it?

Have you solved it? how to use your zero-model to obtain the without-zero model.