TypeError: Input 'y' of 'Mul' Op has type float32 that does not match type int64 of argument 'x'

I had a problem when training model in assignment of week 1.
TypeError: Input ‘y’ of ‘Mul’ Op has type float32 that does not match type int64 of argument 'x’
Can anyone help me?
Thanks


1 Like

Hi @thanhxuanup

From the error message, it seems that the argument is passed in int64 type even though it is supposed to be received in float32 type.

Actually, I still don’t understand the details of the cause.
It seems that you are running on Google colab, so it may be related to the version difference of tensorflow.
It may be needed to check the source code of tensorFlow.

As a tentative solution, how about changing the label data type from the original int64 to float32.

Try to the following the codes before you create instances of “train_generator” and “valid_generator”.

train_df[labels] = np.array(train_df[labels]).astype(np.float32)
valid_df[labels] = np.array(valid_df[labels]).astype(np.float32)

Can you check whether the code works?

2 Likes