reid-strong-baseline icon indicating copy to clipboard operation
reid-strong-baseline copied to clipboard

more conciser sampler

Open bnu-wangxun opened this issue 5 years ago • 2 comments

https://github.com/michuanhaohao/reid-strong-baseline/blob/master/data/samplers/triplet_sampler.py

            batch_idxs = []
            for idx in idxs:
                batch_idxs.append(idx)
                if len(batch_idxs) == self.num_instances:
                    batch_idxs_dict[pid].append(batch_idxs)
                    batch_idxs = []

can be replaced with

batch_idxs_dict[label] = [idxs[i*self.num_instances : (i+1)*self.num_instances] for i in range(len(idxs)//self.num_instances)]

which is more concise and easier to understand!

bnu-wangxun avatar Jul 17 '19 03:07 bnu-wangxun

Thank you very much. If you have check the code, you can commit a PR and become a contributor for this project.

michuanhaohao avatar Jul 18 '19 09:07 michuanhaohao

  batch_idxs = batch_idxs_dict[pid].pop(0)

IndexError: pop from empty list

onlinehuazai avatar Apr 21 '21 14:04 onlinehuazai