'How can fit a keras model with a dataframe of numpy arrays?
I want to train a model with self-generated matrices (word vectors).
My data have the following datatypes:
print(type(X))
print(type(X[0]))
print(type(X[0][0]))
print(type(X[0][0][0]))
<class 'pandas.core.series.Series'>
<class 'numpy.ndarray'>
<class 'numpy.ndarray'>
<class 'numpy.float64'>
Then I try to fit my model:
model.fit(X.values, y, epochs=num_epochs, batch_size=128, validation_split = 0.1)
But the following error is thrown:
ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray).
I tried lots of other formats, but it's even throwing errors for tensorflow tensors (EagerTensor)
What is the problem? Which format is expected?
Solution 1:[1]
It's solved using np.stack(X.values)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | nilosch |