我的 LSTM 模型返回空,没有输出,也没有捕获参数

问题描述 投票:0回答:1

我正在使用酒店评论数据集构建用于情感分析的 LSTM 模型。但是,每次运行代码时,模型总是返回空的输出和参数。

我遵循了从清理到标记化、矢量化、编码和填充的许多过程。

enter image description here

参见附图。

我遵循了清理、停用词、标记化、词形还原、矢量化、填充的正常步骤。

我使用以下代码进行最终模型设计:

# Design the model
model = Sequential()
model.add(Embedding(input_dim=len(vocab_int), output_dim=embedding_vector_length, input_length=max_sentence_length))
model.add(SimpleRNN(256, return_sequences=True, dropout=dropout, recurrent_dropout=dropout))
model.add(SimpleRNN(256, dropout=dropout, recurrent_dropout=dropout))
model.add(Dense(2, activation='softmax'))

model.compile(loss = 'categorical_crossentropy', optimizer='adam', metrics=['accuracy'])

print(model.summary())

我期待带有输出层和参数的构建模型,但什么也没得到。

python nlp vectorization lstm sequencing
1个回答
0
投票

首先,为什么使用

categorical_crossentropy
进行二元分类?使用
binary_crossentropy

第二,嵌入层的输入是无,所以你的网络是无

确保你有:

print("X_train shape:", X_train.shape)
print("y_train shape:", y_train.shape) 

print("Vocabulary size:", len(vocab_int))
print("Embedding vector length:", embedding_vector_length)
print("Max sentence length:", max_sentence_length)
print("Input data shape:", X_train.shape)

然后评论一下

© www.soinside.com 2019 - 2024. All rights reserved.