From b010dc4e35d9bfd9a1080583afcf0a3a5838600f Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 4 Nov 2020 18:21:11 -0600 Subject: [PATCH] Fix AttributeError when using tanh with TF 2.3 --- konverter/__main__.py | 2 +- konverter/utils/konverter_support.py | 7 ++++++- pyproject.toml | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/konverter/__main__.py b/konverter/__main__.py index 643b71e..1a9484b 100644 --- a/konverter/__main__.py +++ b/konverter/__main__.py @@ -3,7 +3,7 @@ import konverter from konverter.utils.general import success, info, warning, error, COLORS, color_logo, blue_grad -KONVERTER_VERSION = "v0.2.2" # fixme: unify this +KONVERTER_VERSION = "v0.2.3" # fixme: unify this KONVERTER_LOGO_COLORED = color_logo(KONVERTER_VERSION) diff --git a/konverter/utils/konverter_support.py b/konverter/utils/konverter_support.py index b9dc48c..0d0df76 100644 --- a/konverter/utils/konverter_support.py +++ b/konverter/utils/konverter_support.py @@ -87,7 +87,12 @@ def get_layer_info(self, layer): is_linear = False if layer_class.name not in self.attrs_without_activations: - activation = getattr(layer.activation, '_keras_api_names') + if hasattr(layer.activation, '_keras_api_names'): + activation = getattr(layer.activation, '_keras_api_names') + else: # fixme: TF 2.3 is missing _keras_api_names + activation = 'keras.activations.' + getattr(layer.activation, '__name__') + activation = (activation,) # fixme: expects this as a tuple + if len(activation) == 1: layer_class.info.activation = self.get_class_from_name(activation[0], 'activations') if layer_class.info.activation.name not in self.attrs_without_activations: diff --git a/pyproject.toml b/pyproject.toml index be42c49..077d6b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "keras-konverter" -version = "0.2.2" +version = "0.2.3" description = "A tool to convert simple Keras models to pure Python + NumPy" readme = "README.md" repository = "https://github.com/ShaneSmiskol/Konverter"