1 Star 0 Fork 0

AstoncMatin / keras_compressor

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

keras_compressor

Model compression CLI tool for keras.

How to use it

Requirements

  • Python 3.5, 3.6
  • Keras
    • We tested on Keras 2.0.3 (TensorFlow backend)

Install

$ git clone ${this repository}
$ cd ./keras_compressor
$ pip install .

Compress

Simple example:

$ keras-compressor.py model.h5 compressed.h5

With accuracy parameter error:

$ keras-compressor.py --error 0.001 model.h5 compressed.h5

Help

$ keras-compressor.py --help                                                                               [impl_keras_compressor:keras_compressor]
Using TensorFlow backend.
usage: keras-compressor.py [-h] [--error 0.1]
                           [--log-level {CRITICAL,ERROR,WARNING,INFO,DEBUG}]
                           model.h5 compressed.h5

compress keras model

positional arguments:
  model.h5              target model, whose loss is specified by
                        `model.compile()`.
  compressed.h5         compressed model path

optional arguments:
  -h, --help            show this help message and exit
  --error 0.1           layer-wise acceptable error. If this value is larger,
                        compressed model will be less accurate and achieve
                        better compression rate. Default: 0.1
  --log-level {CRITICAL,ERROR,WARNING,INFO,DEBUG}
                        log level. Default: INFO

How compress it

  • low-rank approximation
    • with SVD (matrix)
    • with Tucker (tensor)

Examples

In example directory, you will find model compression of VGG-like models using MNIST and CIFAR10 dataset.

$ cd ./keras_compressor/example/mnist/

$ python train.py
-> outputs non-compressed model `model_raw.h5`

$ python compress.py
-> outputs compressed model `model_compressed.h5` from `model_raw.h5`

$ python finetune.py
-> outputs finetuned and compressed model `model_finetuned.h5` from `model_compressed.h5`

$ python evaluate.py model_raw.h5
$ python evaluate.py model_compressed.h5
$ python evaluate.py model_finetuned.h5
-> output test accuracy and the number of model parameters

空文件

简介

keras 模型压缩比赛 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/astoncmatin/keras_compressor.git
git@gitee.com:astoncmatin/keras_compressor.git
astoncmatin
keras_compressor
keras_compressor
master

搜索帮助