8fae3aef46180186d420db3ec88fc747261f0d5c,models/ShowTellModel.py,ShowTellModel,_sample,#ShowTellModel#Any#Any#Any#Any#,120

Before Change


            output, state = self.core(xt.unsqueeze(0), state)
            logprobs = F.log_softmax(self.logit(self.dropout(output.squeeze(0))), dim=1)

        return torch.cat([_.unsqueeze(1) for _ in seq], 1), torch.cat([_.unsqueeze(1) for _ in seqLogprobs], 1)

After Change


            logprobs = F.log_softmax(self.logit(self.dropout(output.squeeze(0))), dim=1)

            // sample the next word
            if t == self.seq_length + 1: // skip if we achieve maximum length
                break
            if sample_max:
                sampleLogprobs, it = torch.max(logprobs.data, 1)
                it = it.view(-1).long()
            else:
                if temperature == 1.0:
                    prob_prev = torch.exp(logprobs.data).cpu() // fetch prev distribution: shape Nx(M+1)
                else:
                    // scale logprobs by temperature
                    prob_prev = torch.exp(torch.div(logprobs.data, temperature)).cpu()
                it = torch.multinomial(prob_prev, 1).cuda()
                sampleLogprobs = logprobs.gather(1, it) // gather the logprobs at sampled positions
                it = it.view(-1).long() // and flatten indices for downstream processing

            if t >= 1:
                // stop when all finished
                if t == 1:
                    unfinished = it > 0
                else:
                    unfinished = unfinished * (it > 0)
                it = it * unfinished.type_as(it)
                seq[:,t-1] = it //seq[t] the input of t+2 time step
                seqLogprobs[:,t-1] = sampleLogprobs.view(-1)
                if unfinished.sum() == 0:
                    break
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: ruotianluo/self-critical.pytorch
Commit Name: 8fae3aef46180186d420db3ec88fc747261f0d5c
Time: 2018-05-30
Author: rluo@ttic.edu
File Name: models/ShowTellModel.py
Class Name: ShowTellModel
Method Name: _sample


Project Name: ruotianluo/self-critical.pytorch
Commit Name: 8fae3aef46180186d420db3ec88fc747261f0d5c
Time: 2018-05-30
Author: rluo@ttic.edu
File Name: models/ShowTellModel.py
Class Name: ShowTellModel
Method Name: _sample


Project Name: ultralytics/yolov3
Commit Name: e4d62de5bc12d1e411adbfe4b76f15d157d77c65
Time: 2019-02-18
Author: glenn.jocher@ultralytics.com
File Name: utils/utils.py
Class Name:
Method Name: non_max_suppression