(self, batch_size, hidden_size, vocab_size, beam_size, max_unroll, batch_position)
Beam class for beam search
Beam class for beam search
Beam class for beam search
def __init__(self, batch_size, hidden_size, vocab_size, beam_size, max_unroll, batch_position):
        """Beam class for beam search"""
        self.batch_size = batch_size
        self.hidden_size = hidden_size
        self.vocab_size = vocab_size
        self.beam_size = beam_size
        self.max_unroll = max_unroll

        # batch_position [batch_size]
        #   [0, beam_size, beam_size * 2, .., beam_size * (batch_size-1)]
        #   Points where batch starts in [batch_size x beam_size] tensors
        #   Ex. position_idx[5]: when 5-th batch starts
        self.batch_position = batch_position

        self.log_probs = list()  # [(batch*k, vocab_size)] * sequence_length
        self.scores = list()  # [(batch*k)] * sequence_length
        self.back_pointers = list()  # [(batch*k)] * sequence_length
        self.token_ids = list()  # [(batch*k)] * sequence_length
        # self.hidden = list()  # [(num_layers, batch*k, hidden_size)] * sequence_length

        self.metadata = {
            'inputs': None,
            'output': None,
            'scores': None,
            'length': None,
            'sequence': None,
        }
def __init__ ( self , batch_size , hidden_size , vocab_size , beam_size , max_unroll , batch_position ) : self . batch_size = batch_size self . hidden_size = hidden_size self . vocab_size = vocab_size self . beam_size = beam_size self . max_unroll = max_unroll # batch_position [batch_size] #   [0, beam_size, beam_size * 2, .., beam_size * (batch_size-1)] #   Points where batch starts in [batch_size x beam_size] tensors #   Ex. position_idx[5]: when 5-th batch starts self . batch_position = batch_position self . log_probs = list ( ) # [(batch*k, vocab_size)] * sequence_length self . scores = list ( ) # [(batch*k)] * sequence_length self . back_pointers = list ( ) # [(batch*k)] * sequence_length self . token_ids = list ( ) # [(batch*k)] * sequence_length # self.hidden = list()  # [(num_layers, batch*k, hidden_size)] * sequence_length self . metadata = { 'inputs' : None , 'output' : None , 'scores' : None , 'length' : None , 'sequence' : None , }