nmt/ion_beam_search_decoder.py
def finalize(self, outputs, final_state, sequence_lengths):
    """Finalize and return the predicted_ids.
    Args:
      outputs: An instance of BeamSearchDecoderOutput.
      final_state: An instance of BeamSearchDecoderState. Passed through to the
        output.
      sequence_lengths: An `int64` tensor shaped `[batch_size, beam_width]`.
        The sequence lengths determined for each beam during decode.
        **NOTE** These are ignored; the updated sequence lengths are stored in
        `final_state.lengths`.
    Returns:
      outputs: An instance of `FinalBeamSearchDecoderOutput` where the
        predicted_ids are the result of calling _gather_tree.
      final_state: The same input instance of `BeamSearchDecoderState`.
    """
    del sequence_lengths
    # Get max_sequence_length across all beams for each batch.
    max_sequence_lengths = math_ops.to_int32(
        math_ops.reduce_max(final_state.lengths, axis=1))
    predicted_ids = beam_search_ops.gather_tree(
        outputs.predicted_ids,
        outputs.parent_ids,
        max_sequence_lengths=max_sequence_lengths,
        end_token=self._end_token)
    # predicted_ids = tf.Print(predicted_ids, [tf.shape(predicted_ids), predicted_ids], summarize=50)
    
    step_probs = gather_tree(
        outputs.step_log_probs,
        outputs.parent_ids)
    # predicted_ids = tf.Print(predicted_ids, [tf.shape(step_probs), step_probs], summarize=50, message="step")
    
    outputs = FinalBeamSearchDecoderOutput(
        beam_search_decoder_output=outputs, predicted_ids=predicted_ids, step_log_probs=step_probs)
    return outputs, final_state
Finalize and return the predicted_ids.
    Args:
      outputs: An instance of BeamSearchDecoderOutput.
      final_state: An instance of BeamSearchDecoderState. Passed through to the
        output.
      sequence_lengths: An `int64` tensor shaped `[batch_size, beam_width]`.
        The sequence lengths determined for each beam during decode.
        **NOTE** These are ignored; the updated sequence lengths are stored in
        `final_state.lengths`.
    Returns:
      outputs: An instance of `FinalBeamSearchDecoderOutput` where the
        predicted_ids are the result of calling _gather_tree.
      final_state: The same input instance of `BeamSearchDecoderState`.
    
Finalize and return the predicted_ids.
Finalize and return the predicted_ids .
def finalize(self, outputs, final_state, sequence_lengths):
    del sequence_lengths
    max_sequence_lengths = math_ops.to_int32(
        math_ops.reduce_max(final_state.lengths, axis=1))
    predicted_ids = beam_search_ops.gather_tree(
        outputs.predicted_ids,
        outputs.parent_ids,
        max_sequence_lengths=max_sequence_lengths,
        end_token=self._end_token)
    step_probs = gather_tree(
        outputs.step_log_probs,
        outputs.parent_ids)
    outputs = FinalBeamSearchDecoderOutput(
        beam_search_decoder_output=outputs, predicted_ids=predicted_ids, step_log_probs=step_probs)
    return outputs, final_state
def finalize ( self , outputs , final_state , sequence_lengths ) : del sequence_lengths max_sequence_lengths = math_ops . to_int32 ( math_ops . reduce_max ( final_state . lengths , axis = 1 ) ) predicted_ids = beam_search_ops . gather_tree ( outputs . predicted_ids , outputs . parent_ids , max_sequence_lengths = max_sequence_lengths , end_token = self . _end_token ) step_probs = gather_tree ( outputs . step_log_probs , outputs . parent_ids ) outputs = FinalBeamSearchDecoderOutput ( beam_search_decoder_output = outputs , predicted_ids = predicted_ids , step_log_probs = step_probs ) return outputs , final_state
Finalize and return the predicted_ids.
Finalize and return the predicted_ids .
"""Finalize and return the predicted_ids.
    Args:
      outputs: An instance of BeamSearchDecoderOutput.
      final_state: An instance of BeamSearchDecoderState. Passed through to the
        output.
      sequence_lengths: An `int64` tensor shaped `[batch_size, beam_width]`.
        The sequence lengths determined for each beam during decode.
        **NOTE** These are ignored; the updated sequence lengths are stored in
        `final_state.lengths`.
    Returns:
      outputs: An instance of `FinalBeamSearchDecoderOutput` where the
        predicted_ids are the result of calling _gather_tree.
      final_state: The same input instance of `BeamSearchDecoderState`.
    """ # Get max_sequence_length across all beams for each batch. # predicted_ids = tf.Print(predicted_ids, [tf.shape(predicted_ids), predicted_ids], summarize=50) # predicted_ids = tf.Print(predicted_ids, [tf.shape(step_probs), step_probs], summarize=50, message="step")
An instance of `FinalBeamSearchDecoderOutput` where the
predicted_ids are the result of calling _gather_tree.
final_state: The same input instance of `BeamSearchDecoderState`.
An instance of ` FinalBeamSearchDecoderOutput ` where the predicted_ids are the result of calling _gather_tree . final_state : The same input instance of ` BeamSearchDecoderState ` .
outputs
self
outputs
An instance of BeamSearchDecoderOutput.
An instance of BeamSearchDecoderOutput .
final_state
An instance of BeamSearchDecoderState. Passed through to the
output.
An instance of BeamSearchDecoderState . Passed through to the output .
sequence_lengths
An `int64` tensor shaped `[batch_size, beam_width]`.
The sequence lengths determined for each beam during decode.
NOTE** These are ignored; the updated sequence lengths are stored in
`final_state.lengths`.
An ` int64 ` tensor shaped ` [ batch_size beam_width ] ` . The sequence lengths determined for each beam during decode . NOTE ** These are ignored ; the updated sequence lengths are stored in ` final_state . lengths ` .