tensorflow.python.framework.errors_impl.InvalidArgumentError: Specified a list with shape [32,3] from a tensor with shape [2,3] [[node model/lstm/TensorArrayUnstack/TensorListFromTensor (defined at /PycharmProjects/Latestcodeemma/venv/lib/python3.8/site-packages/kerashypetune/kerashypetune.py:206) ]] [Op:__inference_train_function_10478] #48236
Labels
stat:awaiting response
Status - Awaiting response from author
type:others
issues not falling in bug, perfromance, support, build and install or feature
We are writing a neural network for text analysis. To do this we want to perform a gridsearch for the hyperparameters. However, in our code we get the following error:
tensorflow.python.framework.errors_impl.InvalidArgumentError: Specified a list with shape [32,3] from a tensor with shape [2,3]
[[node model/lstm/TensorArrayUnstack/TensorListFromTensor (defined at PycharmProjects/venv/lib/python3.8/site-packages/kerashypetune/kerashypetune.py:206) ]] [Op:__inference_train_function_10478]
Function call stack:
train_function
This would indicate that some dimensions do not line up, however, all our dimensions of the data set are correct as we can fit the model correctly, but the grid search does not work.
The full error is:
Traceback (most recent call last):
File "/Users/Desktop/grid_search.py", line 141, in
kgs.search([X_pricing_train, X_reports_train], Y_train, validation_data=([X_pricing_test, X_reports_test], Y_test), callbacks=callback)
File "/Users/PycharmProjects/venv/lib/python3.8/site-packages/kerashypetune/kerashypetune.py", line 206, in search
model.fit(x = x,
File "/Users/PycharmProjects/venv/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py", line 1100, in fit
tmp_logs = self.train_function(iterator)
File "/Users/PycharmProjects/venv/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 828, in call
result = self._call(*args, **kwds)
File "/Users/PycharmProjects/venv/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 855, in _call
return self._stateless_fn(*args, **kwds) # pylint: disable=not-callable
File "/Users/PycharmProjects/venv/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 2942, in call
return graph_function._call_flat(
File "/Users/PycharmProjects/venv/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 1918, in _call_flat
return self._build_call_outputs(self._inference_function.call(
File "/Users/PycharmProjects//venv/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 555, in call
outputs = execute.execute(
File "/Users/PycharmProjects/venv/lib/python3.8/site-packages/tensorflow/python/eager/execute.py", line 59, in quick_execute
tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
tensorflow.python.framework.errors_impl.InvalidArgumentError: Specified a list with shape [32,3] from a tensor with shape [2,3]
[[node model/lstm/TensorArrayUnstack/TensorListFromTensor (defined at /PycharmProjects/venv/lib/python3.8/site-packages/kerashypetune/kerashypetune.py:206) ]] [Op:__inference_train_function_10478]
Function call stack:
train_function
Does someone know how to solve this error or where it could potentially go wrong? In the form of what kind of dimensions might not line up?
The way we defined our grid search is the following:
kerasgridsearch = KerasGridSearch(hypermodel, param_grid, monitor = 'val_loss', greater_is_better=False, tuner_verbose=1)
callback = K.callbacks.EarlyStopping(monitor=monitor)
kerasgridsearcg.search([X_1_train, X_2_train], Y_train, validation_data=([X_1_test, X_2_test], Y_test), callbacks=callback)
The text was updated successfully, but these errors were encountered: