diff --git a/custom_layers.py b/custom_layers.py index 9038419..c761481 100644 --- a/custom_layers.py +++ b/custom_layers.py @@ -1,6 +1,8 @@ -from keras import initializations from keras.engine import Layer, InputSpec - +try: + from keras import initializations +except ImportError: + from keras import initializers as initializations import keras.backend as K class Scale(Layer): @@ -45,8 +47,8 @@ class Scale(Layer): self.input_spec = [InputSpec(shape=input_shape)] shape = (int(input_shape[self.axis]),) - self.gamma = self.gamma_init(shape, name='{}_gamma'.format(self.name)) - self.beta = self.beta_init(shape, name='{}_beta'.format(self.name)) + self.gamma = K.variable(self.gamma_init(shape), name='{}_gamma'.format(self.name)) + self.beta = K.variable(self.beta_init(shape), name='{}_beta'.format(self.name)) self.trainable_weights = [self.gamma, self.beta] if self.initial_weights is not None: