I was trying to solve this problem
ValueError: `logits` and `labels` must have the same shape, received ((None, 1) vs (None, 2)).
when trying to run this code:
tuner.search(x_train, y_train, batch_size=50,
validation_data = (x_test, y_test),
epochs=100, callbacks=[stop_early])
And I found this here on Stack Overflow:
tuner.search(x_train, [y_train[:, 0], y_train[:, 1]], batch_size=50,
validation_data = (x_test, [y_test[:, 0], y_test[:, 1]] ),
epochs=100, callbacks=[stop_early])
now, I'm getting this error:
AttributeError Traceback (most recent call last)
<ipython-input-28-73685d0b2fe7> in <module>
1 tuner.search(x_train, [y_train[:, 0], y_train[:, 1]], batch_size=50,
2 validation_data = (x_test, [y_test[:, 0], y_test[:, 1]] ),
----> 3 epochs=100, callbacks=[stop_early])
6 frames
/usr/local/lib/python3.7/dist-packages/keras_tuner/engine/base_tuner.py in search(self, *fit_args, **fit_kwargs)
181
182 self.on_trial_begin(trial)
--> 183 results = self.run_trial(trial, *fit_args, **fit_kwargs)
184 # `results` is None indicates user updated oracle in `run_trial()`.
185 if results is None:
/usr/local/lib/python3.7/dist-packages/keras_tuner/tuners/hyperband.py in run_trial(self, trial, *fit_args, **fit_kwargs)
382 fit_kwargs["epochs"] = hp.values["tuner/epochs"]
383 fit_kwargs["initial_epoch"] = hp.values["tuner/initial_epoch"]
--> 384 return super(Hyperband, self).run_trial(trial, *fit_args, **fit_kwargs)
385
386 def _build_model(self, hp):
/usr/local/lib/python3.7/dist-packages/keras_tuner/engine/tuner.py in run_trial(self, trial, *args, **kwargs)
293 callbacks.append(model_checkpoint)
294 copied_kwargs["callbacks"] = callbacks
--> 295 obj_value = self._build_and_fit_model(trial, *args, **copied_kwargs)
296
297 histories.append(obj_value)
/usr/local/lib/python3.7/dist-packages/keras_tuner/engine/tuner.py in _build_and_fit_model(self, trial, *args, **kwargs)
220 hp = trial.hyperparameters
221 model = self._try_build(hp)
--> 222 results = self.hypermodel.fit(hp, model, *args, **kwargs)
223 tuner_utils.validate_trial_results(
224 results, self.oracle.objective, "HyperModel.fit()"
/usr/local/lib/python3.7/dist-packages/keras_tuner/engine/hypermodel.py in fit(self, hp, model, *args, **kwargs)
138 If return a float, it should be the `objective` value.
139 """
--> 140 return model.fit(*args, **kwargs)
141
142
/usr/local/lib/python3.7/dist-packages/keras/utils/traceback_utils.py in error_handler(*args, **kwargs)
65 except Exception as e: # pylint: disable=broad-except
66 filtered_tb = _process_traceback_frames(e.__traceback__)
---> 67 raise e.with_traceback(filtered_tb) from None
68 finally:
69 del filtered_tb
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/func_graph.py in autograph_handler(*args, **kwargs)
1127 except Exception as e: # pylint:disable=broad-except
1128 if hasattr(e, "ag_error_metadata"):
-> 1129 raise e.ag_error_metadata.to_exception(e)
1130 else:
1131 raise
AttributeError: 'tuple' object has no attribute 'shape'
It seems like epochs = 100 and callbacks=[stop_early] are the problem, but before adding the modifications to solve the first problem it wasn't happening. How could i solve this?