我想通过考试
X_train_word2vec
矢量作为输入到
Gensim Word2Vec
模型。
numpy.ndarray
,例如:
X_train_word2vec[9] = array([ 19, 7, 1, 20120, 2, 1, 856, 233, 671,
1, 1208, 6016, 2, 32, 0, 0, 0, 0, ....)]
当我运行此代码时:
model_word2vec = models.Word2Vec(X_train_word2vec, size=150, window=9)
model_word2vec.train(X_train_word2vec,total_examples=X_train_word2vec.shape[0], epochs=10)
我得到这个错误:
TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U11') dtype('<U11') dtype('<U11')
我读过
this
int
.
更新:
model_Word2Vec
:
tokenizer = Tokenizer()
tokenizer.fit_on_texts(X)
sequence = tokenizer.texts_to_sequences(X)
seq_max_len = 50
X_seq = pad_sequences(sequenza, maxlen=seq_max_len,padding='post',truncating='post',dtype=int)
X_train_word2vec, X_test_word2vec, y_train_word2vec, y_test_word2vec = train_test_split(X_seq, y_cat, test_size=0.2, random_state=123)