zym1119 / Merge_BN

Merge convolution and batchnorm layers in both Caffe and PyTorch using Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Merge_BN

Merge convolution and batchnorm layers in both Caffe and PyTorch using Python

Basic idea can be found in my CSDN Blog:

Caffe merge bn with equations and explanations

PyTorch merge bn

I wrote the Caffe merge script a long time ago while Pytorch merge script recently, thus may have many difference between them.

Both of them have been tested yet.

Usage

Before using either of them, you should have a no-bn version model first, it means you should have a caffe network prototxt without bn or a pytorch model with all bn layers commented.

After prepare your model and weights, you should modify the path and imports in python scripts

Finally, just run and merge~

BTW, i offered a no-bn version shufflenetv2 model for example

About

Merge convolution and batchnorm layers in both Caffe and PyTorch using Python


Languages

Language:Python 100.0%