Git Product home page Git Product logo

dietnn's Introduction

DietNN

Tool to reduce the size of Neural Networks models

link to presentation

Setup

Clone repository and update python path

repo_name=dietNN # URL of your new repository
username=atinzad # Username for your personal github account
#Clone master
git clone https://github.com/$username/$repo_name
#Or clone a particular branch
my_branch=setup_20180918
git clone -b $my_branch https://github.com/$username/$repo_name

cd $repo_name
echo "export $repo_name=${PWD}" >> ~/.bash_profile
echo "export PYTHONPATH=$repo_name/src:${PYTHONPATH}" >> ~/.bash_profile
source ~/.bash_profile

Create new development branch and switch onto it

branch_name=dev-readme_requisites-20180917 # Name of development branch, of the form 'dev-feature_name-date_of_creation'}}
git checkout -b $branch_name
git push origin $branch_name

Requisites

  • Python 3.6.5
  • Tensorflow 1.10.1 (pip install tensorflow #for latest version)
  • Numpy 1.14.3 (pip install numpy #for latest version)
  • Keras 2.2.2 (pip install keras #for latest version)
  • Kerassurgeon 0.1.1 (pip install kerassurgeon #for latest version)
  • Optional: GraphViz (sudo apt-get install graphviz)
  • Optional: Pydot 1.2.4 (pip install pydot #for latest version)

To install Requisits

cd $repo_name
pip install -r requirements.txt

Once done make sure Tensorflow is running as backend (most likely it is) In python, import keras, then go back to shell (this will create keras.json config file)

python
import keras
exit()

Edit $HOME/.keras/keras.json

{
    "image_data_format": "channels_last",
    "epsilon": 1e-07,
    "floatx": "float32",
    "backend": "tensorflow"
}

Fetch and create h5 parameter file and json model file

cd ~/dietNN/data/raw
python create_models.py #this will create model.json (in KB range) and model.h5 (in MB range)

Run dietNN.py

example on model.json and model.h5 with reduction request of ~30% in footprint

cd ~/dietNN/src/model
python dietNN.py --m ~/dietNN/data/raw/model.json --w ~/dietNN/data/raw/model.h5 --c 30

Alternativly, using a myconfig.txt file contents of myconfig.txt file

--m=~/dietNN/data/raw/model.json
--w=~/dietNN/data/raw/model.h5
--d=~/dietNN/data/raw/dataset/test
--c=30

Then, in the command prompt

python dietNN.py @myconfig.txt

model_small.json and model_small.h5 will be produced and stored in ~/dietNN/src/model folder

Note that model_small.h5 is ~30% smaller than model.h5

dietnn's People

Contributors

atinzad avatar

Stargazers

Pooya Rezaei avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.