Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/DwangoMediaVillage/keras_compressor
Model Compression CLI Tool for Keras.
https://github.com/DwangoMediaVillage/keras_compressor
deep-learning keras machine-learning model-compression
Last synced: about 2 months ago
JSON representation
Model Compression CLI Tool for Keras.
- Host: GitHub
- URL: https://github.com/DwangoMediaVillage/keras_compressor
- Owner: DwangoMediaVillage
- Created: 2017-05-19T10:42:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-09T17:35:00.000Z (over 5 years ago)
- Last Synced: 2024-08-10T14:15:17.287Z (6 months ago)
- Topics: deep-learning, keras, machine-learning, model-compression
- Language: Python
- Homepage: https://nico-opendata.jp/ja/casestudy/model_compression/index.html
- Size: 19.5 KB
- Stars: 157
- Watchers: 11
- Forks: 39
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# keras_compressor
Model compression CLI tool for [keras](https://github.com/fchollet/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.h5compress keras model
positional arguments:
model.h5 target model, whose loss is specified by
`model.compile()`.
compressed.h5 compressed model pathoptional 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.```console
$ 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
```