shaoanlu / faceswap-GAN

A denoising autoencoder + adversarial losses and attention mechanisms for face swapping.
3.38k stars 844 forks source link

AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu' #54

Open DrZepox opened 6 years ago

DrZepox commented 6 years ago
  1. Define Models Cell 3

Error:


AttributeError Traceback (most recent call last)

in () ----> 1 encoder = Encoder() 2 decoder_A = Decoder_ps() 3 decoder_B = Decoder_ps() 4 5 x = Input(shape=IMAGE_SHAPE) in Encoder(nc_in, input_size) 57 x = Dense(4*4*1024)(x) 58 x = Reshape((4, 4, 1024))(x) ---> 59 out = upscale_ps(512)(x) 60 return Model(inputs=inp, outputs=out) 61 in block(x) 33 def block(x): 34 x = Conv2D(filters*4, kernel_size=3, use_bias=False, kernel_initializer=RandomNormal(0, 0.02), padding='same' )(x) ---> 35 x = LeakyReLU(0.1)(x) 36 x = PixelShuffler()(x) 37 return x C:\VirtualEnvironments\GAN\lib\site-packages\keras\engine\topology.py in __call__(self, inputs, **kwargs) 615 616 # Actually call the layer, collecting output(s), mask(s), and shape(s). --> 617 output = self.call(inputs, **kwargs) 618 output_mask = self.compute_mask(inputs, previous_mask) 619 C:\VirtualEnvironments\GAN\lib\site-packages\keras\layers\advanced_activations.py in call(self, inputs) 44 45 def call(self, inputs): ---> 46 return K.relu(inputs, alpha=self.alpha) 47 48 def get_config(self): C:\VirtualEnvironments\GAN\lib\site-packages\keras\backend\tensorflow_backend.py in relu(x, alpha, max_value) 2916 """ 2917 if alpha != 0.: -> 2918 x = tf.nn.leaky_relu(x, alpha) 2919 else: 2920 x = tf.nn.relu(x) AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu'
rosenb0rg commented 6 years ago

I had the same error and it seems to be fixed by downgrading to Keras 2.1.2. See this thread.