A library for converting Keras neural networks to real-time compatible C.
Project description
keras2c is a library for deploying keras neural networks in C99, using only standard libraries. It is designed to be as simple as possible for real-time applications.
Please cite this paper if you use this work in your research:
R. Conlin, K. Erickson, J. Abbate, and E. Kolemen, “Keras2c: A library for converting Keras neural networks to real-time compatible C,”
Engineering Applications of Artificial Intelligence, vol. 100, p. 104182, Apr. 2021, doi: 10.1016/j.engappai.2021.104182.
Installation
Recommended Installation
The modern way to install keras2c is via pip:
pip install keras2c
To use the original/stable version, use the Release v1.0.2 (https://github.com/PlasmaControl/keras2c/releases/tag/v1.0.2) with the command:
git clone git@github.com:PlasmaControl/keras2c.git --branch v1.0.2
For Windows, make sure that you have gcc installed. We recommend CYGWIN with make and gcc.
Quickstart
keras2c can be used from the command line:
python -m keras2c [-h] [-m] [-t] model_path function_name
A library for converting the forward pass (inference) part of a keras model to
a C function
positional arguments:
model_path File path to saved keras .h5 model file
function_name What to name the resulting C function
optional arguments:
-h, --help show this help message and exit
-m, --malloc Use dynamic memory for large arrays. Weights will be
saved to .csv files that will be loaded at runtime
-t , --num_tests Number of tests to generate. Default is 10
It can also be used within a python environment:
from keras2c import k2c
k2c(model, function_name, malloc=False, num_tests=10, verbose=True)
For more information, see Installation and Usage
Supported Layers
Core Layers: Dense, Activation, Dropout, Flatten, Input, Reshape, Permute, RepeatVector, ActivityRegularization, SpatialDropout1D, SpatialDropout2D, SpatialDropout3D
Convolution Layers: Conv1D, Conv2D, Conv3D, Cropping1D, Cropping2D, Cropping3D, UpSampling1D, UpSampling2D, UpSampling3D, ZeroPadding1D, ZeroPadding2D, ZeroPadding3D
Pooling Layers: MaxPooling1D, MaxPooling2D, AveragePooling1D, AveragePooling2D, GlobalMaxPooling1D, GlobalAveragePooling1D, GlobalMaxPooling2D, GlobalAveragePooling2D, GlobalMaxPooling3D, GlobalAveragePooling3D
Recurrent Layers: SimpleRNN, GRU, LSTM, SimpleRNNCell, GRUCell, LSTMCell
Embedding Layers: Embedding
Merge Layers: Add, Subtract, Multiply, Average, Maximum, Minimum, Concatenate, Dot
Advanced Activation Layers: LeakyReLU, PReLU, ELU, Softmax, ReLU
Normalization Layers: BatchNormalization
Noise Layers: GaussianNoise, GaussianDropout, AlphaDropout
Layer Wrappers: TimeDistributed, Bidirectional
ToDo
Core Layers: Lambda, Masking
Convolution Layers: SeparableConv1D, SeparableConv2D, DepthwiseConv2D, Conv2DTranspose, Conv3DTranspose
Pooling Layers: MaxPooling3D, AveragePooling3D
Locally Connected Layers: LocallyConnected1D, LocallyConnected2D
Recurrent Layers: ConvLSTM2D, ConvLSTM2DCell
Merge Layers: Broadcasting merge between different sizes
Misc: models made from submodels
Contribute
Documentation: https://f0uriest.github.io/keras2c/
Issue Tracker: https://github.com/f0uriest/keras2c/issues
Source Code: https://github.com/f0uriest/keras2c/
License
The project is licensed under the LGPLv3 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file keras2c-2.0.tar.gz.
File metadata
- Download URL: keras2c-2.0.tar.gz
- Upload date:
- Size: 33.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a82fefe7d11fdca7c12b6ad8fdb950a329128b5cad4a618ff67c2de2262ebf45
|
|
| MD5 |
cd6cabaed68f36cdd0a1d429efa71af9
|
|
| BLAKE2b-256 |
e4332576f6646da020b4b1a6d05a5101ce37e01d4dc8f48e5ed83b5976660ff7
|
Provenance
The following attestation bundles were made for keras2c-2.0.tar.gz:
Publisher:
python-publish.yml on PlasmaControl/keras2c
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
keras2c-2.0.tar.gz -
Subject digest:
a82fefe7d11fdca7c12b6ad8fdb950a329128b5cad4a618ff67c2de2262ebf45 - Sigstore transparency entry: 780394198
- Sigstore integration time:
-
Permalink:
PlasmaControl/keras2c@606db15359489ff4d078a50f4f4b2d996e087e32 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/PlasmaControl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@606db15359489ff4d078a50f4f4b2d996e087e32 -
Trigger Event:
release
-
Statement type:
File details
Details for the file keras2c-2.0-py3-none-any.whl.
File metadata
- Download URL: keras2c-2.0-py3-none-any.whl
- Upload date:
- Size: 27.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b8e47f0a46ba1b683df35895649c7d18297e9dedfd919c9f6f6ac94494214e7
|
|
| MD5 |
387643e847f7660c16dbf334bd44292b
|
|
| BLAKE2b-256 |
2972f2b76c7118dbac42f2ba429a6a4db9f8ba01b0ce3ecd7375b7fb0ec08412
|
Provenance
The following attestation bundles were made for keras2c-2.0-py3-none-any.whl:
Publisher:
python-publish.yml on PlasmaControl/keras2c
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
keras2c-2.0-py3-none-any.whl -
Subject digest:
5b8e47f0a46ba1b683df35895649c7d18297e9dedfd919c9f6f6ac94494214e7 - Sigstore transparency entry: 780394201
- Sigstore integration time:
-
Permalink:
PlasmaControl/keras2c@606db15359489ff4d078a50f4f4b2d996e087e32 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/PlasmaControl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@606db15359489ff4d078a50f4f4b2d996e087e32 -
Trigger Event:
release
-
Statement type: