nilosch
nilosch

Reputation: 162

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?

Upvotes: 0

Views: 846

Answers (1)

nilosch
nilosch

Reputation: 162

It's solved using np.stack(X.values)

Upvotes: 1

Related Questions