LDAM-DRW icon indicating copy to clipboard operation
LDAM-DRW copied to clipboard

Points for sampler

Open halbielee opened this issue 5 years ago • 5 comments

Thanks for sharing your great job.

I have a question about the point for sampler in your code.

train_sampler is first declared at L167 in cifar_train.py then, train_loader gets the sampler in L169-171.

This seems to be fine in itself. But in the middle of training(train+validation) there is a part which seems to be for sampler in L186-L208. I understand this part is need for LDAM and DRW, but I think this new train_sampler object does not affect train_loader.

How's your opinion? Thnks!

https://github.com/kaidic/LDAM-DRW/blob/3193f05c1e6e8c4798c5419e97c5a479d991e3e9/cifar_train.py#L186-L208

halbielee avatar Nov 22 '19 07:11 halbielee

I think you're right. I also found this issue when running the code. I think it only effects "Resample" and can be fixed by adding a line after the "ImbalancedDatasetSampler" is created to make sure the dataloader use the created sampler.

AlanChou avatar Nov 22 '19 17:11 AlanChou

Thank you for the quick response!

halbielee avatar Nov 22 '19 17:11 halbielee

You should probably wait for the author's response before closing the issue though I think you're right about the question. And it's also better to keep the issue opened before the code is updated. I’m just a random guy which want to help :)

AlanChou avatar Nov 22 '19 17:11 AlanChou

@AlanChou Oh, I see. I thought you were the author. :)

Thank you for the another reply!

halbielee avatar Nov 25 '19 01:11 halbielee

The same question for me. I found it rejected to change the sampler of train_loader after initialization(because the sampler affects shuffle, etc.), so I wonder if I should:

  1. resample and create train_loader each epoch
  2. just resample and create train_loader once before the epoch-loop

yibuxulong avatar Jan 20 '21 03:01 yibuxulong