0

我想在我的编码器-解码器中添加一个预训练的词嵌入。下面是我的代码:

# Define an Encoder
encoder_inputs = Input(shape=(None, nEncoderToken))
encoder = LSTM(embedding_dim, return_state=True)
encoder_outputs, state_h, state_c = encoder(encoder_inputs)
encoder_states = [state_h, state_c]

# Define a Decoder
decoder_inputs = Input(shape=(None, nDecoderToken))
decoder_lstm = LSTM(embedding_dim, return_sequences=True, return_state=True)
decoder_outputs, _, _ = decoder_lstm(decoder_inputs, initial_state=encoder_states)
decoder_dense = Dense(nDecoderToken, activation='softmax')
decoder_outputs = decoder_dense(decoder_outputs)

model = Model([encoder_inputs, decoder_inputs], decoder_outputs)

我尝试了很多方法,但我就是无法得到它。

4

0 回答 0