InvalidArgumentError: Incompatible shapes: [192,3,32,84,5] vs. [64,1,1,1,1] at node random_weighted_average/mul_1 in MuseGAN model

I tried to refactor implement MuseGAN model to add conditional feature. (bottom link)
Based On: https://github.com/davidADSP/GDL_code/blob/tensorflow_2/models/MuseGAN.py

but Error Occured at random_weighted_average/mul_1 in model.

class RandomWeightedAverage(Layer):
    def __init__(self, batch_size):
        super().__init__()
        self.batch_size = batch_size
    """Provides a (random) weighted average between real and generated image samples"""
    def call(self, inputs):
        alpha = K.random_uniform((self.batch_size, 1, 1, 1, 1))
        #print(f'alpha: {alpha.shape}')
        #print(f'input0 : {inputs[0].shape}') #  (None, 4, 16, 84, 5)
        #print(f'input1 : {inputs[1].shape}')
        return (alpha * inputs[0]) + ((1 - alpha) * inputs[1])
#Errors:
#Try Run #1 : Set batch_size = 64 * 3 -> Intented Error  
#  (0) Invalid argument: Incompatible shapes: [192,1,1,1,1] vs. [64,3,32,84,5]  
#    [[{{node random_weighted_average/mul}}]]  
#    [[loss/Identity_1/_4559]]  
#  (1) Invalid argument: Incompatible shapes: [192,1,1,1,1] vs. [64,3,32,84,5]  
#    [[{{node random_weighted_average/mul}}]]  

#Try Run #2 : Set batch_size = 64 -> Not Intented. I wonder why is 192 size??  
# (0) Invalid argument: Incompatible shapes: [192,3,32,84,5] vs. [64,1,1,1,1]  
#    [[{{node random_weighted_average/mul_1}}]]  
#    [[loss/Identity_1/_4559]]  
#  (1) Invalid argument: Incompatible shapes: [192,3,32,84,5] vs. [64,1,1,1,1]  
#    [[{{node random_weighted_average/mul_1}}]]  

Tried code (base code + conditional feature)
My Full Code : https://github.com/ikarus-999/MuseGAN_TF2.x/blob/main/experiment.ipynb
Model code #1: https://github.com/ikarus-999/MuseGAN_TF2.x/blob/main/museGAN2.py
Model module #2: https://github.com/ikarus-999/MuseGAN_TF2.x/blob/main/module1.py

Q : I don’t know Why 192 size in Try Run #2?

Source: Python-3x Questions

LEAVE A COMMENT