Keras LSTM输入与层不兼容,预期ndim = 3,发现ndim = 4

Car*_*ven 5 python lstm keras

我正在尝试嵌入LSTM,并在Keras中包含以下内容:

inp = Input(shape=(20, 1))
x = Embedding(total_words, 256)(inp)
x = LSTM(128)(x)
output = Dense(1, activation ='softmax')(x)
Run Code Online (Sandbox Code Playgroud)

但是,我不明白为什么我总是在行中出现以下错误x = LSTM(128)(x)

ValueError: Input 0 is incompatible with layer lstm_12: expected ndim=3, found ndim=4
Run Code Online (Sandbox Code Playgroud)

我错过了什么?