From 10d6a2bde393e52daf6e066dc03f0a8479674aad Mon Sep 17 00:00:00 2001 From: Anisha Keshavan Date: Sat, 3 Feb 2018 08:41:51 -0800 Subject: [PATCH] fix to load model saved from old keras version --- keras/layers/advanced_activations.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/keras/layers/advanced_activations.py b/keras/layers/advanced_activations.py index 38163df1869..26b31c2adc9 100644 --- a/keras/layers/advanced_activations.py +++ b/keras/layers/advanced_activations.py @@ -40,7 +40,11 @@ class LeakyReLU(Layer): def __init__(self, alpha=0.3, **kwargs): super(LeakyReLU, self).__init__(**kwargs) self.supports_masking = True - self.alpha = K.cast_to_floatx(alpha) + # fix from https://github.com/keras-team/keras/pull/7784 + if isinstance(alpha, dict): + self.alpha = K.cast_to_floatx(alpha['value']) + else: + self.alpha = K.cast_to_floatx(alpha) def call(self, inputs): return K.relu(inputs, alpha=self.alpha)