PacktPublishing / Neural-Network-Projects-with-Python

Neural Network Projects with Python, Published by Packt
MIT License
301 stars 185 forks source link

Chapter 7 Error #8

Open yunyonggeun opened 3 years ago

yunyonggeun commented 3 years ago

I am studying machine learning hard with your book. I managed to follow up to Chapter 7, but I have not been able to solve the problems encountered in Chapter 7. I need your help. the problem is

Epoch 1/10

TypeError Traceback (most recent call last)

in () ----> 1 model.fit( [training_pairs[:, 0], training_pairs[:, 1]], training_labels, batch_size=64, epochs=10) 10 frames /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/func_graph.py in wrapper(*args, **kwargs) 971 except Exception as e: # pylint:disable=broad-except 972 if hasattr(e, "ag_error_metadata"): --> 973 raise e.ag_error_metadata.to_exception(e) 974 else: 975 raise TypeError: in user code: /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:806 train_function * return step_function(self, iterator) :53 contrasive_loss * return K.mean(Y_true*K.square(D) + (1- Y_true)* K.maximum((margin-D), 0)) /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py:1141 binary_op_wrapper raise e /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py:1125 binary_op_wrapper return func(x, y, name=name) /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py:1457 _mul_dispatch return multiply(x, y, name=name) /usr/local/lib/python3.6/dist-packages/tensorflow/python/util/dispatch.py:201 wrapper return target(*args, **kwargs) /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py:509 multiply return gen_math_ops.mul(x, y, name) /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_math_ops.py:6176 mul "Mul", x=x, y=y, name=name) /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py:506 _apply_op_helper inferred_from[input_arg.type_attr])) TypeError: Input 'y' of 'Mul' Op has type float32 that does not match type int64 of argument 'x'.
Kai-Taka commented 3 years ago

just had the same error and I would like to notify that someone already solved it https://github.com/PacktPublishing/Neural-Network-Projects-with-Python/issues/7