72e28f315e6458993407beb4d7041ccebca90735,parlai/core/torch_ranker_agent.py,TorchRankerAgent,_build_candidates,#TorchRankerAgent#Any#Any#Any#,138

Before Change


            if batch.candidate_vecs is None:
                raise ValueError("If using candidate source "inline", then "
                    "bath.candidate_vecs can not be None.")
            if batchsize > 1 and (
                torch.any(batch.candidate_vecs[0] != batch.candidate_vecs[1])):
                raise ValueError("All examples in a batch must have the same "
                    "candidate set.")

            cands = batch.candidates[0]
            cand_vecs, _ = padded_tensor(batch.candidate_vecs[0],
                use_cuda=self.use_cuda)
            if label_vecs is not None:

After Change


            cands = batch.candidates
            // batch.candidate_vecs is a [batchsize] list of [num_cand] lists of
            // [seq_len] LongTensors
            max_len = max(len(t) for t_list in batch.candidate_vecs for t in t_list)
            cand_tensor_list = [self._cat_and_pad(cand_list, max_len=max_len,
                use_cuda=self.use_cuda) for cand_list in batch.candidate_vecs]
            // cand_tensor_list is a [batchsize] list of [num_cand, seq_len] LongTensors
            cand_vecs = torch.stack(cand_tensor_list, 0)
            // cands is a [batchsize, cand_len, seq_len] LongTensor
            if label_vecs is not None:
                label_inds = label_vecs.new_empty(batchsize)
                for i, label_vec in enumerate(label_vecs):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 8

Instances


Project Name: facebookresearch/ParlAI
Commit Name: 72e28f315e6458993407beb4d7041ccebca90735
Time: 2018-10-16
Author: bhancock@fb.com
File Name: parlai/core/torch_ranker_agent.py
Class Name: TorchRankerAgent
Method Name: _build_candidates


Project Name: deepgram/kur
Commit Name: b01ea16c4fadeb271c2bde653947d92048f367c8
Time: 2017-03-21
Author: ajsyp@syptech.net
File Name: kur/backend/keras_backend.py
Class Name: KerasBackend
Method Name: _restore_keras


Project Name: quantumlib/Cirq
Commit Name: baddb11a55a68c29cdc319bc9dde6e0a24ad32fe
Time: 2020-12-08
Author: dabacon@gmail.com
File Name: cirq/ionq/serializer.py
Class Name: Serializer
Method Name: serialize