密集层的输出是什么?

时间:2019-04-06 13:16:49

标签: keras lstm recurrent-neural-network word-embedding seq2seq

我正在使用基于LSTM RNN的编解码器模型进行seq2seq预测。密集层将输出什么?我很困惑是直接为输出单词嵌入输出序列的矢量还是令牌IDS。

谢谢。

这是模型的结构:

    shared_embedding_layer = Embedding(vocab_size,
                                   embedding_matrix.shape[1],
                                   weights = [embedding_matrix],
                                   trainable = False,
                                   name = 'embedding_layer')


encoder_inputs = Input(batch_shape = (my_batch_size, num_encoder_tokens), name = 'encoder_input')

encoder_embedding_layer = shared_embedding_layer(encoder_inputs)

encoder_lstm = LSTM(latent_dim,
               return_sequences = False,
               return_state = True,
               name = 'encoder_lstm')

_, state_h, state_c = encoder_lstm(encoder_embedding_layer)

encoder_states = [state_h, state_c]

decoder_inputs = Input(batch_shape = (my_batch_size, num_decoder_tokens), name = 'decoder_input')
decoder_embedding_layer = shared_embedding_layer(decoder_inputs)

decoder_lstm = LSTM(latent_dim,
                    return_state = False,
                    return_sequences = True,
                    name = 'decoder_lstm')

decoder_lstm_output = decoder_lstm(decoder_embedding_layer, initial_state = encoder_states)

time_distributed_decoder_dense = TimeDistributed(Dense(num_decoder_tokens,
                      activation = 'softmax',
                      name = 'decoder_dense'))

decoder_outputs = time_distributed_decoder_dense(decoder_lstm_output)

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

0 个答案:

没有答案