Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using gen_weight_File #10

Open
MichaelB0312 opened this issue Apr 25, 2023 · 1 comment
Open

using gen_weight_File #10

MichaelB0312 opened this issue Apr 25, 2023 · 1 comment
Labels
question Further information is requested

Comments

@MichaelB0312
Copy link

Hi,

I'm missing what are you doing with all the weights in the csv file which gen_weight_File has created.

How do you use them afterward?

Thanks ;)

@YuanGongND
Copy link
Owner

YuanGongND commented Apr 25, 2023

Hi,

The weight file is used here:

psla/src/run.py

Lines 82 to 85 in 46a53b9

if args.bal == True:
print('balanced sampler is being used')
samples_weight = np.loadtxt(args.data_train[:-5] + '_weight.csv', delimiter=',')
sampler = WeightedRandomSampler(samples_weight, len(samples_weight), replacement=True)

Basically, in gen_weight_file, the weight of each sample is sum(1/class_frequency), note for audioset, each sample has multiple classes, that's why sum is needed. The idea is to give rare class higher weight.

Then in

sampler = WeightedRandomSampler(samples_weight, len(samples_weight), replacement=True)
, the weight is used to sampling in dataloading, i.e., a sound clip with rare class is more likely to be seen by the model. The algorithm can be found in the paper.

-Yuan

@YuanGongND YuanGongND added the question Further information is requested label Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants