def _tile_encoders_for_beamsearch(self, projected_sentinel):
sentinel_batch_size = tf.shape(projected_sentinel)[0]
encoders_batch_size = tf.shape(
self.encoder_projections_for_ctx[0])[0]
modulo = tf.mod(sentinel_batch_size, encoders_batch_size)
with tf.control_dependencies([tf.assert_equal(modulo, 0)]):
beam_size = tf.div(sentinel_batch_size,
encoders_batch_size)
return [tf.tile(proj, [beam_size, 1, 1])
for proj in self.encoder_projections_for_ctx]
评论列表
文章目录