face-clustering
face-clustering copied to clipboard
Type error during fitting
When I fit the model, I received this error: TypeError: Expected int64 passed to parameter 'y' of op 'Maximum', got 1e-12 of type 'float' instead. Error: Expected int64, but got 1e-12 of type 'float'. which can be traced back to the warning TypeError: not all arguments converted during string formatting during the train generator, is there any fix for this?
Thank you
Hi, without the full traceback is a little bit difficult to understand where the error is, could you provide it?
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:13: UserWarning:
Model.fit_generatoris deprecated and will be removed in a future version. Please useModel.fit, which supports generators. del sys.path[0] Epoch 1/12TypeError Traceback (most recent call last)
in () 11 shuffle=True, 12 callbacks=[checkpoint], ---> 13 verbose=1 14 ) 2 frames /usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/func_graph.py in autograph_handler(*args, **kwargs) 1145 except Exception as e: # pylint:disable=broad-except 1146 if hasattr(e, "ag_error_metadata"): -> 1147 raise e.ag_error_metadata.to_exception(e) 1148 else: 1149 raise
TypeError: in user code:
File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1021, in train_function * return step_function(self, iterator) File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1010, in step_function ** outputs = model.distribute_strategy.run(run_step, args=(data,)) File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1000, in run_step ** outputs = model.train_step(data) File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 860, in train_step loss = self.compute_loss(x, y, y_pred, sample_weight) File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 919, in compute_loss y, y_pred, sample_weight, regularization_losses=self.losses) File "/usr/local/lib/python3.7/dist-packages/keras/engine/compile_utils.py", line 201, in __call__ loss_value = loss_obj(y_t, y_p, sample_weight=sw) File "/usr/local/lib/python3.7/dist-packages/keras/losses.py", line 141, in __call__ losses = call_fn(y_true, y_pred) File "/usr/local/lib/python3.7/dist-packages/keras/losses.py", line 245, in call ** return ag_fn(y_true, y_pred, **self._fn_kwargs) File "/usr/local/lib/python3.7/dist-packages/keras/losses.py", line 2199, in cosine_similarity y_true = tf.linalg.l2_normalize(y_true, axis=axis) TypeError: Expected int64 passed to parameter 'y' of op 'Maximum', got 1e-12 of type 'float' instead. Error: Expected int64, but got 1e-12 of type 'float'.
Here are the library versions I am using: OpenCV 4.1.2 Keras 2.8.0 Pandas 1.3.5 Numpy 1.21.5
If it helps a link to the notebook https://colab.research.google.com/drive/1eFgQqA6KC1acSCXbzc8ru5ffea5Oim7Q#scrollTo=dlfjYC2DrXhI
Thank you
Hi, you can try a couple of things:
- Change the loss function to
binary_crossentropy. - And/or replace all the
kerasrelated imports withtensorflow.keras, instead.
Let me know if the issue persists