Ejemplo n.º 1
0
 def create_beam_op(self, models, len_normalization):
     self.len_normalization = len_normalization
     self.models = models
     beam_funs = [model.beam_fun for model in models]
     initial_data = [model.initial_data for model in models]
     beam_output = beam_search.rnn_beam_search(beam_funs, initial_data, self.max_output_len[0], self.beam_size,
                                               len_normalization, temperature=self.temperature,
                                               parallel_iterations=self.decoders[0].parallel_iterations,
                                               swap_memory=self.decoders[0].swap_memory)
     self.beam_outputs, self.beam_scores = beam_output
Ejemplo n.º 2
0
    def create_beam_op(self, models, beam_size, len_normalization, early_stopping=True):
        self.beam_size = beam_size
        self.len_normalization = len_normalization
        self.models = models

        if beam_size > 1 or len(models) > 1:
            beam_funs = [model.beam_fun for model in models]
            initial_data = [model.initial_data for model in models]
            beam_output = beam_search.rnn_beam_search(beam_funs, initial_data, self.max_output_len[0], beam_size,
                                                      len_normalization, early_stopping, temperature=self.temperature)
            self.beam_outputs, self.beam_scores = beam_output