使用Convlstm2d和关注层预测结果时值错误?

时间:2019-05-24 09:44:31

标签: tensorflow keras lstm attention-model

我正在将注意机制与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)

0 个答案:

没有答案