{"id":22035935,"url":"https://github.com/jzz24/pytorch_quantization","last_synced_at":"2025-05-07T19:44:57.530Z","repository":{"id":54338666,"uuid":"224433601","full_name":"Jzz24/pytorch_quantization","owner":"Jzz24","description":"A pytorch implementation of dorefa quantization","archived":false,"fork":false,"pushed_at":"2019-12-30T11:57:31.000Z","size":906,"stargazers_count":113,"open_issues_count":7,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T13:28:16.300Z","etag":null,"topics":["bn-fold","dorefa","imagenet","nvidia-dali","quantization","resnet"],"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/Jzz24.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}},"created_at":"2019-11-27T13:08:44.000Z","updated_at":"2025-02-22T20:38:30.000Z","dependencies_parsed_at":"2022-08-13T12:30:51.674Z","dependency_job_id":null,"html_url":"https://github.com/Jzz24/pytorch_quantization","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jzz24%2Fpytorch_quantization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jzz24%2Fpytorch_quantization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jzz24%2Fpytorch_quantization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jzz24%2Fpytorch_quantization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jzz24","download_url":"https://codeload.github.com/Jzz24/pytorch_quantization/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252947057,"owners_count":21829903,"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","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":["bn-fold","dorefa","imagenet","nvidia-dali","quantization","resnet"],"created_at":"2024-11-30T10:29:11.436Z","updated_at":"2025-05-07T19:44:57.411Z","avatar_url":"https://github.com/Jzz24.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dorefa-net \nA pytorch implementation of [dorefa](https://arxiv.org/abs/1606.06160).The code is inspired by [LaVieEnRoseSMZ](https://github.com/LaVieEnRoseSMZ/AutoBNN) and [zzzxxxttt](https://github.com/kuangliu/pytorch-cifar).\n\n## Requirements\n* python \u003e 3.5\n* torch \u003e= 1.1.0\n* torchvision \u003e= 0.4.0\n* tb-nightly, future (for tensorboard)\n* nvidia-dali \u003e= 0.12 (faster [dataloader](https://docs.nvidia.com/deeplearning/sdk/dali-developer-guide/docs/index.html#))\n\n## Cifar-10 Accuracy\n\nQuantized model are trained from scratch\n\n| Model | W_bit | A_bit | Acc |\n| :-: | :-: | :-: |:-: |\n| resnet-18      | 32   |   32     | 94.71%     |\n| resnet-18      |   4   |   4      |  94.36%     |\n| resnet-18      |   1   |   4      |  93.87%     |\n\n\n## ImageNet Accuracy\n\nQuantized model are trained from scratch\n\n| Model | W_bit | A_bit | Top1 |Top5 |\n| :-: | :-: | :-: |:-: |:-: |\n| resnet-18      | 32   |   32     | 69.80%     |89.32%  |\n| resnet-18      | 4   |   4     | 66.60%     |87.15%  |\n\n## Usages\nDownload the ImageNet dataset and move validation images to labeled subfolders.To do this, you can use the following [script](https://raw.githubusercontent.com/soumith/imagenetloader.torch/master/valprep.sh)\n- To train the model \n```\npython3 cifar_train_eval.py    \npython3 imagenet_torch_loader --multiprocessing-distributed    or    python3 imagenet_dali_loader.py \n```\n- To check the tensorboard log \n\t```\n\ttensorboard --logdir='your_log_dir'\n\t```\n\n\tthen navigating to https://localhost:6006 .\n\n- To test the quantized model and bn fused \n\t- convert to the quantized model for inference\n\t```\n\tpython3 test_fused_quant_model.py\n\t```\n\t- test bn fuse on the float model\n\t```\n\tpython3 bn_fuse.py\n\t```\n\tObviously, this fusion method is not suitable for quantized models. We will change the bn fuse in the future according to the [paper](https://arxiv.org/pdf/1806.08342.pdf) section 3.2.2.\n\t\n\tThis bn fuse test result is not serious. However, it is OK to explain the problem qualitatively.\n\t\n\t\n| Model on CPU | before fuse | after fuse | \n| :-: | :-: | :-: |\n| resnet-18      | 0.74 s   |   0.51 s     | \n| resnet-34      |   1.41 s   |   0.92 s      |  \n| resnet-50      |   1.96 s   |   1.02 s      |  \n\n\n## To do\n- [x]    Train on imagenet2012\n- [x]    Fold bn\n- [x]    Test speedup from quantization and bn fold\n- [ ]    Deploy models to embedded devices\n- [ ]    ...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjzz24%2Fpytorch_quantization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjzz24%2Fpytorch_quantization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjzz24%2Fpytorch_quantization/lists"}