YuanGongND / psla

Code for the TASLP paper "PSLA: Improving Audio Tagging With Pretraining, Sampling, Labeling, and Aggregation".
BSD 3-Clause "New" or "Revised" License
139 stars 16 forks source link

using gen_weight_File #10

Open MichaelB0312 opened 1 year ago

MichaelB0312 commented 1 year ago

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 commented 1 year ago

Hi,

The weight file is used here:

https://github.com/YuanGongND/psla/blob/46a53b9f86c95faae73ebd38777e2a6c370dd877/src/run.py#L82-L85

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 https://github.com/YuanGongND/psla/blob/46a53b9f86c95faae73ebd38777e2a6c370dd877/src/run.py#L85, 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