pytorch-pruning icon indicating copy to clipboard operation
pytorch-pruning copied to clipboard

Any suggestions on how can I extend this code for MobileNetV2?

Open nekulkarni opened this issue 6 years ago • 9 comments

The given example of VGG16 works well for me. I want to try out this method on a MobiletNetV2 model. VGG16 has a pretty simple structure: a sequence of convs and other layers. However, MobiletNetV2 has a peculiar structure contains InvertedResidualBlocks, which is making the extension hard for me.

Any suggestions?

nekulkarni avatar Sep 06 '18 02:09 nekulkarni

Did you find a solution to this?

aprams avatar Sep 29 '18 19:09 aprams

@aprams Yes I did, had to do multiple changes to make that work. I basically flattened the mobilenetv2 model into a flat model before feeding into this code (dealing with the residual links is the trickiest part in the flattening process). Secondly, I changed prune.py significantly to address batchnorm layers, and depthwise convs. I hope that helps.

nekulkarni avatar Oct 20 '18 08:10 nekulkarni

@nekulkarni Can you share me your code,please? I need to prune the mobilenetv2 for the school project but I am the beginner for python.

NCHW avatar Nov 30 '18 16:11 NCHW

@aprams Yes I did, had to do multiple changes to make that work. I basically flattened the mobilenetv2 model into a flat model before feeding into this code (dealing with the residual links is the trickiest part in the flattening process). Secondly, I changed prune.py significantly to address batchnorm layers, and depthwise convs. I hope that helps.

Thanks for sharing, could you please share more about how to deal with batchnorm layers? Thanks so much.

viviov avatar Dec 18 '18 02:12 viviov

@nekulkarni , I have pruned mobilenetv2 correctly, but the pruned model is difficult to train on imagenet, the accuracy is very low( I train with a 1080Ti, batchsize=96, lr=0.045, weight decay=0.00004, and decrease the lr 0.98 for each epoch, and i also try lr =0.1, lr = lr * (0.1 ** (epoch // 30)) ). can you tell me your data set and accuracy. thank you very much!

CF2220160244 avatar Dec 22 '18 05:12 CF2220160244

It seems that mobilenetv2 convergence slowly !

CF2220160244 avatar Dec 22 '18 06:12 CF2220160244

@nekulkarni Can you share me your code about mobilenetv2 pruned ,please? I am a beginner. Thank you very much!

guanhuiyan avatar May 10 '19 02:05 guanhuiyan

@viviov Can you share me your code about mobilenetv2 pruned ,please? I am a beginner. Thank you very much!

guanhuiyan avatar May 11 '19 03:05 guanhuiyan

@nekulkarni Can you share the code with me also? I want to know how to deal with batch norm layers. Thank you very much.!!

bharat3012 avatar Aug 02 '19 12:08 bharat3012