All Projects → Raukk → Tf Keras Surgeon

Raukk / Tf Keras Surgeon

Licence: other
Pruning and other network surgery for trained TF.Keras models.

Projects that are alternatives of or similar to Tf Keras Surgeon

Densedepth
High Quality Monocular Depth Estimation via Transfer Learning
Stars: ✭ 963 (+3752%)
Mutual labels:  jupyter-notebook, deep-neural-networks, keras-tensorflow
Dlpython course
Примеры для курса "Программирование глубоких нейронных сетей на Python"
Stars: ✭ 266 (+964%)
Mutual labels:  jupyter-notebook, deep-neural-networks, keras-tensorflow
Distiller
Neural Network Distiller by Intel AI Lab: a Python package for neural network compression research. https://intellabs.github.io/distiller
Stars: ✭ 3,760 (+14940%)
Mutual labels:  jupyter-notebook, deep-neural-networks, pruning
Stock Analysis Engine
Backtest 1000s of minute-by-minute trading algorithms for training AI with automated pricing data from: IEX, Tradier and FinViz. Datasets and trading performance automatically published to S3 for building AI training datasets for teaching DNNs how to trade. Runs on Kubernetes and docker-compose. >150 million trading history rows generated from +5000 algorithms. Heads up: Yahoo's Finance API was disabled on 2019-01-03 https://developer.yahoo.com/yql/
Stars: ✭ 605 (+2320%)
Mutual labels:  jupyter-notebook, deep-neural-networks
Labml
🔎 Monitor deep learning model training and hardware usage from your mobile phone 📱
Stars: ✭ 508 (+1932%)
Mutual labels:  jupyter-notebook, keras-tensorflow
Music recommender
Music recommender using deep learning with Keras and TensorFlow
Stars: ✭ 528 (+2012%)
Mutual labels:  jupyter-notebook, keras-tensorflow
Predictive Maintenance Using Lstm
Example of Multiple Multivariate Time Series Prediction with LSTM Recurrent Neural Networks in Python with Keras.
Stars: ✭ 352 (+1308%)
Mutual labels:  deep-neural-networks, keras-tensorflow
Pytorch Multi Style Transfer
Neural Style and MSG-Net
Stars: ✭ 687 (+2648%)
Mutual labels:  jupyter-notebook, deep-neural-networks
Speech Emotion Analyzer
The neural network model is capable of detecting five different male/female emotions from audio speeches. (Deep Learning, NLP, Python)
Stars: ✭ 633 (+2432%)
Mutual labels:  jupyter-notebook, deep-neural-networks
Gans In Action
Companion repository to GANs in Action: Deep learning with Generative Adversarial Networks
Stars: ✭ 748 (+2892%)
Mutual labels:  jupyter-notebook, deep-neural-networks
Deep Embedded Memory Networks
https://arxiv.org/abs/1707.00836
Stars: ✭ 19 (-24%)
Mutual labels:  jupyter-notebook, deep-neural-networks
Docs
TensorFlow documentation
Stars: ✭ 4,999 (+19896%)
Mutual labels:  jupyter-notebook, deep-neural-networks
Aimet
AIMET is a library that provides advanced quantization and compression techniques for trained neural network models.
Stars: ✭ 453 (+1712%)
Mutual labels:  deep-neural-networks, pruning
Awesome Emdl
Embedded and mobile deep learning research resources
Stars: ✭ 554 (+2116%)
Mutual labels:  deep-neural-networks, pruning
Easy Deep Learning With Keras
Keras tutorial for beginners (using TF backend)
Stars: ✭ 367 (+1368%)
Mutual labels:  jupyter-notebook, deep-neural-networks
Saliency
TensorFlow implementation for SmoothGrad, Grad-CAM, Guided backprop, Integrated Gradients and other saliency techniques
Stars: ✭ 648 (+2492%)
Mutual labels:  jupyter-notebook, deep-neural-networks
Deep Learning Time Series
List of papers, code and experiments using deep learning for time series forecasting
Stars: ✭ 796 (+3084%)
Mutual labels:  jupyter-notebook, deep-neural-networks
All Classifiers 2019
A collection of computer vision projects for Acute Lymphoblastic Leukemia classification/early detection.
Stars: ✭ 22 (-12%)
Mutual labels:  jupyter-notebook, deep-neural-networks
Deepfake Detection
DeepFake Detection: Detect the video is fake or not using InceptionResNetV2.
Stars: ✭ 23 (-8%)
Mutual labels:  jupyter-notebook, deep-neural-networks
Action Recognition Visual Attention
Action recognition using soft attention based deep recurrent neural networks
Stars: ✭ 350 (+1300%)
Mutual labels:  jupyter-notebook, deep-neural-networks

Tf-Keras-Surgeon

Note: This is a Port for TensorFlow.Keras, for the normal Keras version see the source Project Keras-Surgeon: https://github.com/BenWhetton/keras-surgeon

Installation

pip install tfkerassurgeon

Introduction

This is a port of Keras-Surgeon by BenWhetton to work with the newer versions Tensorflow tf.keras and TF 2.0 which has a few differences from normal keras (which causes bugs).

Note: Currently, versions of Tensorflow newer than 1.13.1 have Breaking changes due to the TF 2.0 Migration.

I am working on getting it working for 1.14 and 2.0 Beta, but that will require major changes (and will probably not be backwards compatible). This will be updated once those changes are released.

Quick Example:

https://colab.research.google.com/gist/Raukk/49cbf50e564271a6b5f4fc596459d5e9/example_lenet_mnist.ipynb

Goals:

Current:

This is not intended to do anything more than the original, so, most of the code and documentation will remain unchanged. It is primarily a port and Bug Fixes.

Future:

Adapt the Code to be modular and extensible such that new code has the option of being a seperate Plugin (under it's own project and license). Modules like;

  1. Additional Identifier methods to select which nodes to prune.
  2. Additional Actions or types of pruning (set weights to zero, reinitialize, etc).
  3. Additional layers supported.

Note: this is the Unedited README from the Keras-Surgeon Project:

Keras-Surgeon README:

Introduction

Keras-surgeon provides simple methods for modifying trained Keras models. The following functionality is currently implemented:

  • delete neurons/channels from layers
  • delete layers
  • insert layers
  • replace layers

Keras-surgeon is compatible with any model architecture. Any number of layers can be modified in a single traversal of the network.

These kinds of modifications are sometimes known as network surgery which inspired the name of this package.

The operations module contains simple methods to perform network surgery on a single layer within a model.
Example usage:

from kerassurgeon.operations import delete_layer, insert_layer, delete_channels
# delete layer_1 from a model
model = delete_layer(model, layer_1)
# insert new_layer_1 before layer_2 in a model
model = insert_layer(model, layer_2, new_layer_3)
# delete channels 0, 4 and 67 from layer_2 in model
model = delete_channels(model, layer_2, [0,4,67])

The Surgeon class enables many modifications to be performed in a single operation.
Example usage:

# delete channels 2, 6 and 8 from layer_1 and insert new_layer_1 before 
# layer_2 in a model
from kerassurgeon import Surgeon
surgeon = Surgeon(model)
surgeon.add_job('delete_channels', model, layer_1, channels=[2, 6, 8])
surgeon.add_job('insert_layer', model, layer_2, new_layer=new_layer_1)
new_model = surgeon.operate()

The identify module contains methods to identify which channels to prune.

Documentation

The docstrings and this file contain all of the documentation. Standalone documentation may be added in the future.

Motivation

This project was motivated by my interest in deep learning and desire to experiment with some of the pruning methods I have read about in the research literature. I could not find an easy way to prune neurons from Keras models.

I hope I have created something which will be useful to others.

Installation

pip install kerassurgeon

Examples:

Examples are in kerassurgeon.examples.
Both examples identify which neurons to prune using the method described in Hu et al. (2016): those which have the highest Average Percentage of Zeros (APoZ).
Neither example is particularly good at demonstrating the benefits of pruning but they show how Keras-surgeon can be used.
I would welcome any good examples from other users.

Pruning Lenet trained on MNIST:

lenet_minst is a very simple example showing the effects of deleting channels from a simple Lenet style network trained on MNIST. It demonstrates using the simple methods from kerasurgeon.operations.

Inception V3 fine-tuned on flowers data-set:

This example shows how to delete channels from many layers simultaneously using the Surgeon Class.
It is in two parts:
inception_flowers_tune shows how to fine-tune the Inception V3 model on a small flowers data set (based on a combination of Tensorflow tutorial and Keras blog post).
inception_flowers_prune demonstrates deleting channels from many layers simultaneously using the Surgeon Class.

Limitations:

Only python 3 is currently supported. Only python 3.5 has been tested.
The following layers are not fully supported; delete_channels might not work on models containing these layers (it depends if they are affected by the operation):

  • Lambda
  • SeparableConv2D
  • Conv2DTranspose
  • LocallyConnected1D
  • LocallyConnected2D
  • TimeDistributed
  • Bidirectional
  • Dot
  • PReLU

Recurrent layers’ sequence length must be defined.
The model’s input shape must be defined.

Future improvements:

Architecture:

Investigate more efficient ways of modifying a layer in the middle of a model without re-building the whole network.

Performance:

This package has not yet been optimised for performance. It can certainly be improved.

Tests:

Write unit tests for the utility functions.
This package pretty tightly coupled with Keras which makes unit testing difficult. Some component tests have been written but it needs more work.

Examples

Write better examples.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].