Я пытаюсь обратить внимание на модель кодера-декодера. Но при объединении выходного сигнала декодера в плотный слой я получаю сообщение об ошибке. Ниже приведен код, за которым следует ошибка (код работает / тренируется без внимания, просто говоря): -
inputs = Input(shape=(timesteps, features))
#Initial state and cell state of the final BLSTM layer as initial states to Decoder(Done)
#Encoder
masked_encoder_inputs = layers.Masking(mask_value=0)(inputs)
encoder_dropout = (TimeDistributed(Dropout(rate = dropout_rateE)))(masked_encoder_inputs)
encoder_out1,f_h1, f_c1, b_h1, b_c1 = Bidirectional(LSTM(latent_dim, return_sequences = True,return_state=True))(encoder_dropout)
encoder_out2,f_h2, f_c2, b_h2, b_c2 = Bidirectional(LSTM(latent_dim, return_sequences = True, return_state=True,dropout=0.15))(encoder_out1)
encoder_out3,f_h3, f_c3, b_h3, b_c3 = Bidirectional(LSTM(latent_dim, return_sequences = True, return_state=True,dropout= 0.15))(encoder_out2)
state_h3 = Concatenate()([f_h3, b_h3])
state_c3 = Concatenate()([f_c3, b_c3])
encoder_states = [state_h3, state_c3]
#Decoder
decoder_inputs = (encoder_out3)
decoder_lstm = LSTM(latent_dim*2, return_state=True,return_sequences=True)
decoder_dropout = (TimeDistributed(Dropout(rate = dropout_rateD)))(decoder_inputs)
decoder_outputs, _, _ = decoder_lstm(decoder_dropout, initial_state = encoder_states)
#Attention
attention = dot([decoder_outputs, encoder_out3], axes=[2, 2])
attention = Activation('softmax')(attention)
context = dot([attention, encoder_out3], axes=[2,1])
decoder_combined_context = Concatenate([context, decoder_outputs])
# compute importance for each step
#attention = Dense(1, activation='tanh')(activations)
#attention = Flatten()(attention)
#attention = Activation('softmax')(attention)
#attention = RepeatVector(units)(attention)
#attention = Permute([2, 1])(attention)
#sent_representation = merge([activations, attention], mode='mul')
decoder_outputs = TimeDistributed(Dense(features, activation='relu'))(decoder_combined_context)
model = Model(inputs, decoder_outputs)
Я получаю следующую ошибку: -
as_list() is not defined on an unknown TensorShape.
для второй последней строки в фрагменте кода: -
decoder_outputs = TimeDistributed(Dense(features, activation='relu'))(decoder_combined_context)