Course 4 Week4 - Exercise 3 - compute_layer_style_cost¶/// TypeError: x and y must have the same dtype, got tf.float32 != tf.int32

I think it’s a mistake to use tf.square with the constant integer terms there (n_C, n_W and n_H). Try using np.square and using floating point constants like 2. and 4. instead of 2 and 4. The problem is caused by TF being much more strict about integer types, whereas base python and numpy are a bit more forgiving.

1 Like