Deep-Learning-Experiments icon indicating copy to clipboard operation
Deep-Learning-Experiments copied to clipboard

module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu'

Open thiglu opened this issue 7 years ago • 1 comments

AttributeError Traceback (most recent call last) in () 190 191 if name == 'main': --> 192 mnist_dcgan = MNIST_DCGAN() 193 timer = ElapsedTimer() 194 mnist_dcgan.train(train_steps=10000, batch_size=256, save_interval=500)

in init(self) 135 136 self.DCGAN = DCGAN() --> 137 self.discriminator = self.DCGAN.discriminator_model() 138 self.adversarial = self.DCGAN.adversarial_model() 139 self.generator = self.DCGAN.generator()

in discriminator_model(self) 111 optimizer = RMSprop(lr=0.0002, decay=6e-8) 112 self.DM = Sequential() --> 113 self.DM.add(self.discriminator()) 114 self.DM.compile(loss='binary_crossentropy', optimizer=optimizer, metrics=['accuracy']) 115 return self.DM

in discriminator(self) 47 input_shape = (self.img_rows, self.img_cols, self.channel) 48 self.D.add(Conv2D(depth*1, 5, strides=2, input_shape=input_shape, padding='same')) ---> 49 self.D.add(LeakyReLU(alpha=0.2)) 50 self.D.add(Dropout(dropout)) 51

E:\Anaconda3\envs\python35\lib\site-packages\keras\models.py in add(self, layer) 490 output_shapes=[self.outputs[0]._keras_shape]) 491 else: --> 492 output_tensor = layer(self.outputs[0]) 493 if isinstance(output_tensor, list): 494 raise TypeError('All layers in a Sequential model '

E:\Anaconda3\envs\python35\lib\site-packages\keras\engine\topology.py in call(self, inputs, **kwargs) 617 618 # Actually call the layer, collecting output(s), mask(s), and shape(s). --> 619 output = self.call(inputs, **kwargs) 620 output_mask = self.compute_mask(inputs, previous_mask) 621

E:\Anaconda3\envs\python35\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):

E:\Anaconda3\envs\python35\lib\site-packages\keras\backend\tensorflow_backend.py in relu(x, alpha, max_value) 2919 """ 2920 if alpha != 0.: -> 2921 x = tf.nn.leaky_relu(x, alpha) 2922 else: 2923 x = tf.nn.relu(x)

thiglu avatar Mar 26 '18 17:03 thiglu

change keras to 2.1.2 solved my problem. you can use conda install keras=2.1.2 .

moetmd avatar May 08 '18 08:05 moetmd