如何适合keras模型与numpy数组的数据框架?



我想用自生成矩阵(词向量)训练一个模型。

我的数据有以下数据类型:

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'>

然后我试着适合我的模型:

model.fit(X.values, y, epochs=num_epochs, batch_size=128, validation_split = 0.1)

但是会抛出以下错误:

ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray).

我尝试了很多其他格式,但它甚至抛出错误的tensorflow张量(EagerTensor)

有什么问题吗?使用哪种格式?

使用np.stack(X.values)解决

最新更新