Beispiel #1
0
 def handle(self, t_input: sockeye.inference.TranslatorInput,
            t_output: sockeye.inference.TranslatorOutput):
     """
     :param t_input: Translator input.
     :param t_output: Translator output.
     """
     plot_attention(t_output.attention_matrix, t_input.tokens,
                    t_output.tokens,
                    "%s_%d.png" % (self.plot_prefix, t_input.id))
Beispiel #2
0
 def handle(self,
            t_input: inference.TranslatorInput,
            t_output: inference.TranslatorOutput,
            t_walltime: float = 0.):
     """
     :param t_input: Translator input.
     :param t_output: Translator output.
     :param t_walltime: Total wall-clock time for translation.
     """
     plot_attention(t_output.attention_matrix, t_input.tokens,
                    t_output.tokens,
                    "%s_%d.png" % (self.plot_prefix, t_input.sentence_id))
Beispiel #3
0
 def handle(self,
            t_input: inference.TranslatorInput,
            t_output: inference.TranslatorOutput,
            t_walltime: float = 0.):
     """
     :param t_input: Translator input.
     :param t_output: Translator output.
     :param t_walltime: Total wall-clock time for translation.
     """
     plot_attention(t_output.attention_matrix,
                    t_input.tokens,
                    t_output.tokens,
                    "%s_%d.png" % (self.plot_prefix, t_input.sentence_id))
Beispiel #4
0
 def handle(self,
            t_input: inference.TranslatorInput,
            t_output: inference.TranslatorOutput,
            t_walltime: float = 0.):
     """
     :param t_input: Translator input.
     :param t_output: Translator output.
     :param t_walltime: Total wall-clock time for translation.
     """
     if self.output_attention_type == C.ENCODER_DECODER_ATTENTION:
         plot_attention(t_output.attention_matrix, t_input.tokens,
                        t_output.tokens,
                        "%s_%d.png" % (self.plot_prefix, t_input.id))
     elif self.output_attention_type == C.ENCODER_SELF_ATTENTION:
         plot_attention(t_output.attention_matrix, t_input.tokens,
                        t_input.tokens,
                        "%s_%d.png" % (self.plot_prefix, t_input.id))
     else:
         plot_attention(t_output.attention_matrix,
                        ['<s>'] + t_output.tokens, t_output.tokens,
                        "%s_%d.png" % (self.plot_prefix, t_input.id))