I'm trying to calculate a simple loss function for a mixture density network. The output's shape (batch_size=128,2) and the mu parameter's shape is (batch_size, 2* Num_mixes). To be able to calculate their difference, I need to tile the output so it has the same shape as the mu but I get the subject error
I don't know why despite the (128,2) shape of the output, its rank is 0. Can you please help?
def calc_pdf(y, mu, var):
"""Calculate component density"""
print(y.shape)
print(mu.shape)
value = tf.subtract(y, mu)**2
value = (1/tf.math.sqrt(2 * np.pi * var)) * tf.math.exp((-1/(2*var)) * value)
print(value.shape)
return value
y shape is (128, 2)
mu shape is (128, 60)
y rank is Tensor("Rank:0", shape=(), dtype=int32)
ValueError: Shape must be rank 1 but is rank 0 for 'Tile' (op: 'Tile') with input shapes: [128,2], [].