diff --git a/README.md b/README.md index d5b79ad..fe02336 100644 --- a/README.md +++ b/README.md @@ -211,11 +211,13 @@ A few notes: | `BatchNormalization` | Available | Available | | #### Keras Activation functions - | Model | Implementation | Test | Notes | - | ---------------------------- | --------------- | --------- | ----------------------------- | - | `tanh` | Available | Available | | - | `sigmoid` | Available | Available | | - | `relu` | Available | Available | | + | Model | Implementation | Test | Notes | + |-----------| --------------- | --------- |--------------------------------| + | `tanh` | Available | Available | | + | `sigmoid` | Available | Available | | + | `relu` | Available | Available | | + | `elu` | Available | | | + | `celu` | Available | | Only for alpha=1 (celu == elu) | ## Running tests diff --git a/scikinC/layers/BaseLayerConverter.py b/scikinC/layers/BaseLayerConverter.py index df70e77..e505149 100644 --- a/scikinC/layers/BaseLayerConverter.py +++ b/scikinC/layers/BaseLayerConverter.py @@ -17,7 +17,9 @@ def activate (self, x): elif activation == 'tanh': return "%(x)s = tanh(%(x)s);" % {'x':x} elif activation == 'relu': - return "%(x)s = %(x)s > 0. ? %(x)s : 0.;" % {'x':x} + return "%(x)s = %(x)s > 0. ? %(x)s : 0.;" % {'x':x} + elif activation == 'celu' or activation == 'elu': + return "%(x)s = %(x)s > 0. ? %(x)s : exp(%(x)s) - 1;" % {'x': x} elif activation == 'linear': return "" else: diff --git a/setup.py b/setup.py index 226ee40..6cc100f 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name='scikinC', # Required - version="0.2.8", # Required + version="0.2.9", # Required description='A converter for scikit learn and keras to hardcoded C function', long_description=long_description, long_description_content_type='text/markdown', # Optional (see note above) diff --git a/test/test_keras.py b/test/test_keras.py index 2d6c456..cc95f72 100644 --- a/test/test_keras.py +++ b/test/test_keras.py @@ -42,6 +42,8 @@ def classifier_dense(): tf.keras.layers.Dense(16, activation='tanh'), tf.keras.layers.Dense(16, activation='sigmoid'), tf.keras.layers.Dense(16, activation='relu'), + tf.keras.layers.Dense(16, activation='elu' if hasattr(tf.keras.activations, 'elu') else 'linear'), + tf.keras.layers.Dense(16, activation='celu' if hasattr(tf.keras.activations, 'celu') else 'linear'), tf.keras.layers.Dense(16), tf.keras.layers.Dense(1, activation='sigmoid') ])