【发布时间】:2021-07-14 06:29:31
【问题描述】:
我在文本分析中使用一维卷积。我有大约 488,000 个句子,每个单词有 20 个单词,每个单词的向量维度为 100。
单词到维度为 100 的向量:
model1 = gensim.models.Word2Vec(data, min_count = 1, size = 100, window = 5)
帖子字数上限:
max_length=20
X 训练和 X 验证张量的形状:(390763, 20, 100) (97691, 20, 100)
标签序列和标签验证张量的形状:(390763, 7) (97691, 7)
我的模特:
model.add(Embedding(input_dim=vocab_size, output_dim=100, input_length=20))
model.add(Conv1D(filters=128, kernel_size=5, activation='relu',input_shape=(20,100)))
model.add(Dropout(0.25))
model.add(MaxPooling1D(pool_size=3))
model.add(Dense(7, activation="softmax"))
错误:
Input 0 of layer conv1d is incompatible with the layer: expected ndim=3,
found ndim=4. Full shape received: [None, 20, 100, 100]
【问题讨论】:
标签: python tensorflow keras nlp conv-neural-network