Tensorflow LSTM解码器中的启动令牌
我了解编码器-解码器模型,以及编码器的输出如何成为解码器的输入。假设这里我只有解码器模型,我有解码器的初始状态(即,给定了解码器状态输入) 我想将“解码器输入”作为开始标记(例如Tensorflow LSTM解码器中的启动令牌,tensorflow,keras,lstm,mencoder,Tensorflow,Keras,Lstm,Mencoder,我了解编码器-解码器模型,以及编码器的输出如何成为解码器的输入。假设这里我只有解码器模型,我有解码器的初始状态(即,给定了解码器状态输入) 我想将“解码器输入”作为开始标记(例如)。。。但我不知道如何,以什么形式 decoder_lstm = LSTM(n_units, return_sequences=True, return_state=True) decoder_outputs, state_h, state_c = decoder_lstm(decoder_inputs, ini
decoder_lstm = LSTM(n_units, return_sequences=True, return_state=True)
decoder_outputs, state_h, state_c = decoder_lstm(decoder_inputs, initial_state=decoder_states_inputs)
另外,我必须将开始标记添加到我的原始序列中吗?i、 e:
<start> statemnt1
<start> statemnt2
....
statemnt1
声明2
....
如何添加
和
符号实际上取决于您如何实现模型的其余部分,但在大多数情况下,结果是相同的。例如,在中,它将这些符号添加到每个句子中
def preprocess_sentence(w):
# other preprocessing
w = w.rstrip().strip()
# adding a start and an end token to the sentence
# so that the model know when to start and stop predicting.
w = '<start> ' + w + ' <end>'
return w
# rest of the code
# ... word2idx is a dictionary that map words into unique ids
如何添加
和
符号实际上取决于您如何实现模型的其余部分,但在大多数情况下,结果是相同的。例如,在中,它将这些符号添加到每个句子中
def preprocess_sentence(w):
# other preprocessing
w = w.rstrip().strip()
# adding a start and an end token to the sentence
# so that the model know when to start and stop predicting.
w = '<start> ' + w + ' <end>'
return w
# rest of the code
# ... word2idx is a dictionary that map words into unique ids
谢谢,我理解了你答案的第一部分,但你所说的原始解码器输入是什么意思,在我的例子中,初始状态=解码器状态输入???@noor不,你输入网络的是标记化序列。解码器输出比Deocder输入早一个令牌。谢谢,我理解了你答案的第一部分,但你所说的原始解码器输入是什么意思,在我的例子中,初始状态=解码器状态输入???@noor不,是令牌化序列的,你输入到网络中。解码器输出比Deocder输入提前一个令牌。