ryanwongsa / kaggle-birdsong-recognition

1st Place solution to the Cornell Birdcall Identification competition.
https://www.kaggle.com/c/birdsong-recognition
MIT License
150 stars 30 forks source link

Loss confusion #2

Closed jaideep11061982 closed 3 years ago

jaideep11061982 commented 3 years ago

in SEDPosNegloss

could u help explain what is happening here. Why do we assign zero mask in case of sec label >0

<!--StartFragment--> y_ones_mask = torch.ones_like(y_sec_true, requires_grad=False) y_zeros_mask = torch.ones_like(y_sec_true, requires_grad=False) *self.secondary_factor y_secondary_mask = torch.where(y_sec_true &gt; 0.0, y_zeros_mask, y_ones_mask)<!--EndFragment-->

ryanwongsa commented 3 years ago

The loss function that I used in the competition just turned out to be cross entropy. Since I tried different things none of them produced better results that it so you probably can just use the built in Pytorch CE loss.

jaideep11061982 commented 3 years ago

1)we have got secondary classes also so how u converted CE loss to work for this?

2) what are shapes returned below

   bs, c, s = x.shape  
   mixup_lambda = self.mixup_augmenter.get_lambda(batch_size=bs*c, device=x.device)

    bs_al, s_al, c_al = all_labels.shape  
   all_labels = do_mixup(all_labels.reshape(bs_al*s_al,c_al), mixup_lambda).reshape((bs_al*s_al)//2,1,c_al)

i know mixup will mix in odd and even elements together

ryanwongsa commented 3 years ago

1)we have got secondary classes also so how u converted CE loss to work for this?

It is a multi-label classification problem. So it is BCE loss for each of the outputs.

  1. what are shapes returned below ...

If you see the code audioset_tagging_cnn, it contained the original implementation. I just adapted it to my use case. It has been a while since I have looked at the code but if you debug through the code you can see the shapes.

jaideep11061982 commented 3 years ago

Thanks .btw today is last day to join competition. By any chance you can make your mind to join competition through our team ,you can guide us through we will work on for 1 week

On Sat, 22 May 2021, 23:30 Ryan Wong, @.***> wrote:

1)we have got secondary classes also so how u converted CE loss to work for this?

It is a multi-class classification problem. So it is BCE loss for each of the outputs.

  1. what are shapes returned below ...

If you see the code audioset_tagging_cnn https://github.com/qiuqiangkong/audioset_tagging_cnn, it contained the original implementation. I just adapted it to my use case. It has been a while since I have looked at the code but if you debug through the code you can see the shapes.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ryanwongsa/kaggle-birdsong-recognition/issues/2#issuecomment-846443214, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJDFNZFNPTFFSBGNJUQKGADTO7WKXANCNFSM45KVJDXA .

ryanwongsa commented 3 years ago

Sorry, if you are talking about the BirdCLEF 2021 competition, I currently don't have the time to focus on a new competition.

jaideep11061982 commented 3 years ago

Sure , One more thing in your kernel youbset duration as 20 . Did you train model on larger duration if yes how we can map prediction made on larger time sequences to shorter clip prediction for submission .

Any suggestion ?

On Mon, 24 May 2021, 15:29 Ryan Wong, @.***> wrote:

Sorry, if you are talking about the BirdCLEF 2021 competition, I currently don't have the time to focus on a new competition.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ryanwongsa/kaggle-birdsong-recognition/issues/2#issuecomment-846930761, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJDFNZCWMXNHCTIBHNFDMK3TPIPR5ANCNFSM45KVJDXA .

ryanwongsa commented 3 years ago

I am not sure which kernel you are referring to as I didn't use 20 second clips. I used 30 second durations.

I suggest debugging through Arai's notebook to get a better understanding of how attention works with the SED network as once you understand that then you will understand how to use larger durations. Alternatively go through the original author's paper for more details.

jaideep11061982 commented 3 years ago

Thanks for your reply Key issue in competition is domain gap between test and train data that is sound source is different devices for each .

Any good suggestion to address this different data source issue .

On Mon, 24 May 2021, 20:23 Ryan Wong, @.***> wrote:

I am not sure which kernel you are referring to as I didn't use 20 second clips. I used 30 second durations.

I suggest debugging through Arai's notebook https://www.kaggle.com/hidehisaarai1213/introduction-to-sound-event-detection to get a better understanding of how attention works with the SED network as once you understand that then you will understand how to use larger durations. Alternatively go through the original author's paper https://arxiv.org/abs/1912.10211 for more details.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ryanwongsa/kaggle-birdsong-recognition/issues/2#issuecomment-847096059, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJDFNZFS6TLZXVZ3YCSP27LTPJR5TANCNFSM45KVJDXA .

ryanwongsa commented 3 years ago

Questions relating to current Kaggle competitions should be posted on Kaggle: https://www.kaggle.com/c/birdclef-2021/discussion?sort=recent-comments