{"id":30318217,"url":"https://github.com/MIPT-Oulu/pytorch_bn_fusion","last_synced_at":"2025-08-17T20:09:40.179Z","repository":{"id":91586944,"uuid":"142126328","full_name":"imedslab/pytorch_bn_fusion","owner":"imedslab","description":"Batch normalization fusion for PyTorch. This is an archived repository, which is not maintained. ","archived":true,"fork":false,"pushed_at":"2020-04-06T07:31:05.000Z","size":56,"stargazers_count":197,"open_issues_count":3,"forks_count":29,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-08-11T10:26:47.277Z","etag":null,"topics":["batch-normalization","deep-learning","deep-neural-networks","inference-optimization","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imedslab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-24T08:09:01.000Z","updated_at":"2025-04-22T08:04:20.000Z","dependencies_parsed_at":"2023-07-17T01:02:28.154Z","dependency_job_id":null,"html_url":"https://github.com/imedslab/pytorch_bn_fusion","commit_stats":null,"previous_names":["mipt-oulu/pytorch_bn_fusion","imedslab/pytorch_bn_fusion","oulu-imeds/pytorch_bn_fusion"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/imedslab/pytorch_bn_fusion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imedslab%2Fpytorch_bn_fusion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imedslab%2Fpytorch_bn_fusion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imedslab%2Fpytorch_bn_fusion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imedslab%2Fpytorch_bn_fusion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imedslab","download_url":"https://codeload.github.com/imedslab/pytorch_bn_fusion/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imedslab%2Fpytorch_bn_fusion/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270899582,"owners_count":24664720,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["batch-normalization","deep-learning","deep-neural-networks","inference-optimization","pytorch"],"created_at":"2025-08-17T20:04:12.524Z","updated_at":"2025-08-17T20:09:40.168Z","avatar_url":"https://github.com/imedslab.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Batch Norm Fusion for Pytorch\n\n## About \n\nIn this repository, we present a simplistic implementation of batchnorm fusion for the most popular CNN architectures in PyTorch. \nThis package is aimed to speed up the inference at the test time: **expected boost is 30%!** In the future\n\n## How it works\n\nWe know that both - convolution and batchnorm are the linear operations to the data point x, and they can be written in terms of matrix multiplications:\n ![T_{bn}*S{bn}*Conv_W*(x)](https://latex.codecogs.com/gif.latex?T_{bn}*S_{bn}*W_{conv}*x), \n where we first apply convolution to the data, scale it and eventually shift it using the batchnorm-trained parameters.\n\n## Supported architectures\n\nWe support any architecture, where Conv and BN are combined in a Sequential module. \nIf you want to optimize your own networks with this tool, just follow this design. \nFor the conveniece, we wrapped VGG, ResNet and SeNet families to demonstrate how your models can be converted into such format.\n\n- [x] VGG from torchvision.\n- [x] ResNet Family from `torchvision`.\n- [x] SeNet family from `pretrainedmodels`\n\n## How to use\n\n```python\nimport torchvision.models as models\nfrom bn_fusion import fuse_bn_recursively\n\nnet = getattr(models,'vgg16_bn')(pretrained=True)\nnet = fuse_bn_recursively(net)\nnet.eval()\n# Make inference with the converted model\n```\n## TODO\n\n- [ ] Tests.\n- [ ] Performance benchmarks.\n\n## Acknowledgements\n\nThanks to [@ZFTurbo](https://github.com/ZFTurbo) for the idea, discussions and his [implementation for Keras](https://github.com/ZFTurbo/Keras-inference-time-optimizer).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMIPT-Oulu%2Fpytorch_bn_fusion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMIPT-Oulu%2Fpytorch_bn_fusion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMIPT-Oulu%2Fpytorch_bn_fusion/lists"}