在使用tensorflow.keras.models创建一个新的NLP模型时,用的代码:
model = Sequential()
model.add(LSTM(4, input_shape=(maxlen, len(chars))))
model.add(Dropout(0.5)) # 防止过拟合model.add(Dense(len(chars)))model.add(Activation('softmax'))
能够正常训练,但是当我添加一个lstm层时,它报错:
ValueError: Input 0 of layer "lstm_1" is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (None, 4)
麻烦大佬们帮忙看一下怎么回事
model = Sequential()
model.add(LSTM(4, input_shape=(maxlen, len(chars))))
model.add(Dropout(0.5)) # 防止过拟合model.add(Dense(len(chars)))model.add(Activation('softmax'))
能够正常训练,但是当我添加一个lstm层时,它报错:
ValueError: Input 0 of layer "lstm_1" is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (None, 4)
麻烦大佬们帮忙看一下怎么回事