conversation-tensorflow
conversation-tensorflow copied to clipboard
在你的代码中为什么直接去掉左边一个字符,这个有什么讲究
在model.py文件中,对targets的处理你的代码是这样的:
self.decoder_inputs = labels
decoder_input_shift_1 = tf.slice(self.decoder_inputs, [0, 1],
[batch_size, Config.data.max_seq_length-1])
pad_tokens = tf.zeros([batch_size, 1], dtype=tf.int32)
# make target (right shift 1 from decoder_inputs)
self.targets = tf.concat([decoder_input_shift_1, pad_tokens], axis=1)
我看了一些其他人的代码,有些对self.targets直接用label,有些用以下代码,即左边增加<GO>标识符号,右边去掉最后一个字符,这个有啥讲究吗? 其他人的代码:
self.decoder_inputs = labels
# 补充<SOS>,并移除最后一个字符
decoder_input_shift_1 = tf.strided_slice(self.decoder_inputs, [0, 0], [batch_size, -1], [1, 1])
self.targets = tf.concat([tf.fill([batch_size, 1], self.data.PAD_ID), decoder_input_shift_1], 1)