我正在将注意力机制与 convlstm2d 集成。我可以构建和拟合模型,但在预测结果时会出现值错误。我正在使用来自以下地址的注意力层实现: https ://www.kaggle.com/qqgeogor/keras-lstm-attention-glove840b-lb-0-043
X.shape
#(6766, 8, 100)
n_features = 100
n_seq = 4
n_steps = 2
X = X.reshape((X.shape[0], n_seq, 1, n_steps, n_features))
#(6766, 4, 1, 2, 100)
model = Sequential()
model.add(ConvLSTM2D(filters=32, kernel_size=(1,2),return_sequences=True, activation='relu', input_shape=(n_seq, 1, n_steps, n_features)))
model.add(Attention(n_steps))
model.add(Dense(100, activation='relu'))
model.compile(optimizer='adam', loss='mse')
model.summary()
ConvLSTM2D- output shape =(None, 4, 1, 1, 32)
Attention- output shape =(None, 32)
Dense - output shape =(None, 100)
这是我得到的错误:
ValueError: could not broadcast input array from shape (4096,100) into shape (32,100)