ValueError:使用序列 Keras 设置数组元素



我正在构建一个混合的CNN-RNN架构来制作一个预测模型。我已经将Keras实现与TensorFlow一起使用。但是我一直收到此错误-

File "try.py", line 56, in <module>
model.fit(data, labels, epochs=10, batch_size=32)
File "/share/apps/caffe_software/anaconda4.3.1/lib/python2.7/site-packages/keras/models.py", line 845, in fit
initial_epoch=initial_epoch)
File "/share/apps/caffe_software/anaconda4.3.1/lib/python2.7/site-packages/keras/engine/training.py", line 1485, in fit
initial_epoch=initial_epoch)
File "/share/apps/caffe_software/anaconda4.3.1/lib/python2.7/site-packages/keras/engine/training.py", line 1140, in _fit_loop
outs = f(ins_batch)
File "/share/apps/caffe_software/anaconda4.3.1/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 2073, in __call__
feed_dict=feed_dict)
File "/share/apps/caffe_software/anaconda4.3.1/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 778, in run
run_metadata_ptr)
File "/share/apps/caffe_software/anaconda4.3.1/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 954, in _run
np_val = np.asarray(subfeed_val, dtype=subfeed_dtype)
File "/share/apps/caffe_software/anaconda4.3.1/lib/python2.7/site-packages/numpy/core/numeric.py", line 531, in asarray
return array(a, dtype, copy=False, order=order)

值错误:使用序列设置数组元素。

我在这里附加我的代码

import gensim
from gensim.models import word2vec
documents = ["Human machine interface for lab abc computer applications",
             "A survey of user opinion of computer system response time",
             "The EPS user interface management system",
             "System and human system engineering testing of EPS",
             "Relation of user perceived response time to error measurement"]
sentences = [[word for word in document.lower().split()] for document in documents]
word_model = gensim.models.word2vec.Word2Vec(sentences, size=200, min_count = 1, window = 5)
word_vectors = word_model.wv
data = np.array(word_vectors, ndmin = 2, dtype = object) 
labels = np.array([0.214285714286], ndmin = 2 , dtype = object) #A Normalised Class Label Name 

数据变量给出错误它应该是一个 numpy 数组,但它的本质仍然是词向量序列

wv词向量转换为适合插入到Keras模型中的numpy矩阵

最新更新