ebouteillon / freesound-audio-tagging-2019

Freesound Audio Tagging 2019
MIT License
95 stars 15 forks source link

change metrics to accuracy, and got error #2

Closed happyprotean closed 2 years ago

happyprotean commented 4 years ago

Hi sir, I just want to use your model to train my master degree project which is intended to detect baby's cry. I change your dataset to my dataset and do the same thing as you do. The code doesn't change except I change metrics from metrics=[Lwlrap()] to metrics=[accuracy], then I got an error: RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #2 'other'.

Then I use your model and dataset, just change metrics=[accuracy], same error arises. I think you can reproduce this error in your computer.

So is there anything I can do to use accuracy metric?

ebouteillon commented 4 years ago

It is a multi-classification problem, so you should probably use accuracy_thresh instead.

happyprotean commented 4 years ago

Yes, I agree with you. It is a multi-classfication probem and accuracy_thresh should be used. The problem is I want to use this model to detect baby's cry which is a single classification problem. And for baby's cry problem, accuracy should be used. I tried some ways to fix the error but all failed. Can you give me some advice on transfering your model to a single classification problem? Thank you very much.

ebouteillon commented 4 years ago

If you want to use "single" classification instead of multi-classification, then you may consider to switch to use a single label per audio sample. For that, do not use label_delim in label_from_df (see details in fastai documentation). It will instruct fastai to use "classic" classification. Note that it will break code in the notebook expecting multi-classification (like use of lwlrap). Hope it helps.

happyprotean commented 4 years ago

Hi sir, thanks for your advice. Acturally I have tried to use label_from_df('labels') and metrics=accuracy, but there is another Valueerror: "Expected input batch size_size (32) to match target batch_size (1024)"。 I even don't know where the "1024“ comes from. And I google this error but there is no good solution about it. Please help, it almost makes me freak out...

happyprotean commented 4 years ago

Some more details: the audio sample's labels in columns "labels". And data.show_batch(3), plt.show() works good, I can see the pictures with correct labels.