67addeaef37856340f2d220af9a7cad3c4256235,visdialch/decoders/disc.py,DiscriminativeDecoder,forward,#DiscriminativeDecoder#Any#Any#,22

Before Change


        // score each option
        scores = []
        for opt_id in range(num_options):
            opt = options[:, opt_id, :, :]
            opt_len = options_len[:, opt_id]
            opt_embed = self.option_rnn(opt, opt_len)
            scores.append(torch.sum(opt_embed * enc_out, 1))

        // return scores
        return torch.stack(scores, 1)

After Change


        options_embed = self.word_embed(options)

        // shape: (batch_size * num_rounds * num_options, lstm_hidden_size)
        options_embed = self.option_rnn(options_embed, options_length)

        // repeat encoder output for every option
        // shape: (batch_size, num_rounds, num_options, max_sequence_length)
        encoder_output = encoder_output.unsqueeze(2).repeat(1, 1, num_options, 1)

        // shape now same as `options`, can calculate dot product similarity
        // shape: (batch_size * num_rounds * num_options, lstm_hidden_state)
        encoder_output = encoder_output.view(
            batch_size * num_rounds * num_options, self.config["lstm_hidden_size"]
        )

        // shape: (batch_size * num_rounds * num_options)
        scores = torch.sum(options_embed * encoder_output, 1)
        // shape: (batch_size, num_rounds, num_options)
        scores = scores.view(batch_size, num_rounds, num_options)
        return scores
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: batra-mlp-lab/visdial-challenge-starter-pytorch
Commit Name: 67addeaef37856340f2d220af9a7cad3c4256235
Time: 2019-01-03
Author: karandesai281196@gmail.com
File Name: visdialch/decoders/disc.py
Class Name: DiscriminativeDecoder
Method Name: forward


Project Name: cornellius-gp/gpytorch
Commit Name: 8c0361313db0d1c8006f5b81e9310ec2d70aedb3
Time: 2018-11-14
Author: gpleiss@gmail.com
File Name: test/examples/test_batch_svgp_gp_regression.py
Class Name: TestSVGPRegression
Method Name: test_regression_error


Project Name: cornellius-gp/gpytorch
Commit Name: 8c0361313db0d1c8006f5b81e9310ec2d70aedb3
Time: 2018-11-14
Author: gpleiss@gmail.com
File Name: test/examples/test_batch_svgp_gp_regression.py
Class Name: TestSVGPRegression
Method Name: test_regression_error_cuda