davidADSP / GDL_code

The official code repository for examples in the O'Reilly book 'Generative Deep Learning'
GNU General Public License v3.0
1.47k stars 739 forks source link

Error: MuseGan.py  #72

Open t04925yy opened 4 years ago

t04925yy commented 4 years ago

Trouble about from keras.layers.merge import _Merge at second line in MuseGan.py. It seems that _Merge is no longer supported in Keras.

Will you update this file?

t04925yy commented 4 years ago

I'm sorry that I was using old version. Tensorflow2.2 version worked.

NullXeronier commented 3 years ago

Yes, that _Merge is not supported in keras

Edit That RandomWeightAverage function to this...( TF 2.4 works!!! )

class RandomWeightedAverage(tf.keras.layers.Layer):
    def __init__(self, batch_size):
        super().__init__()
        self.batch_size = batch_size

    def call(self, inputs, **kwargs):
        alpha = tf.random_uniform((self.batch_size, 1, 1, 1, 1))
        return (alpha * inputs[0]) + ((1 - alpha) * inputs[1])

    def compute_output_shape(self, input_shape):
        return input_shape[0]