Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

What is the parameter "num_samples_cls"? #9

Open
zs-zhong opened this issue Aug 8, 2020 · 1 comment
Open

What is the parameter "num_samples_cls"? #9

zs-zhong opened this issue Aug 8, 2020 · 1 comment

Comments

@zs-zhong
Copy link

zs-zhong commented Aug 8, 2020

Hi, thanks for your work and sharing!
I have a question about the setting for ClassAwareSampler: num_samples_cls.
Why you set it to 4 in all config.yaml? What does it mean?

@annsonic
Copy link

I found num_samples_cls determines how many samples of one class would present in a batch.
I tried with num_classes=20, batch_size=10 and num_samples_cls=4.
Following is the printed sampled label_id of 5 batches:
batch 1: [15, 15, 15, 15, 7, 7, 7, 7, 9, 9]
batch 2: [9, 9, 0, 0, 0, 0, 4, 4, 4, 4]
batch 3:[17, 17, 17, 17, 1, 1, 1, 1, 6, 6]
batch 4:[ 6, 6, 5, 5, 5, 5, 11, 11, 11, 11]
batch 5:[16, 16, 16, 16, 3, 3, 3, 3, 18, 18]
Don't know why the author chose num_samples_cls to 4. But I guess when batch_size = num_classes * num_samples_cls, this meets the spirit of class-balanced sampling.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants