2a1a6851344172e0134f3c5f4f5c1021975f2812,torchnlp/samplers/bucket_batch_sampler.py,BucketBatchSampler,__iter__,#BucketBatchSampler#,37

Before Change


            batch_size, drop_last)

    def __iter__(self):
        batches = list(super().__iter__())
        if self.last_batch_first:
            last_batch = batches.pop()
        if self.shuffle:

After Change


        if not self.biggest_batches_first:
            return get_batches()
        else:
            batches = list(get_batches())
            indices = heapq.nlargest(
                5,
                range(len(batches)),
                key=lambda i: len(pickle.dumps([self.data[j] for j in batches[i]])))
            front = [batches[i] for i in indices]
            for i in sorted(indices, reverse=True):
                batches.pop(i)
            batches[0:0] = front
            return iter(batches)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 5

Instances


Project Name: PetrochukM/PyTorch-NLP
Commit Name: 2a1a6851344172e0134f3c5f4f5c1021975f2812
Time: 2018-03-11
Author: petrochukm@gmail.com
File Name: torchnlp/samplers/bucket_batch_sampler.py
Class Name: BucketBatchSampler
Method Name: __iter__


Project Name: pgmpy/pgmpy
Commit Name: cb3f1baa785986d61303cabb936a619d64b7d4d9
Time: 2014-12-13
Author: abinash.panda.ece10@itbhu.ac.in
File Name: pgmpy/models/JunctionTree.py
Class Name: JunctionTree
Method Name: get_factors


Project Name: allenai/allennlp
Commit Name: fa34344baffe2f8e2a50d5353a6e05f1ef668b8f
Time: 2018-06-29
Author: joelgrus@gmail.com
File Name: allennlp/data/iterators/bucket_iterator.py
Class Name: BucketIterator
Method Name: _create_batches


Project Name: rail-berkeley/softlearning
Commit Name: 68670f679838f4aa1282eeaf68f764f1d193c206
Time: 2018-05-22
Author: kristian.hartikainen@gmail.com
File Name: sac/envs/random_goal_swimmer_env.py
Class Name: RandomGoalSwimmerEnv
Method Name: log_diagnostics