Open albertnanda opened 3 years ago
Hey, thanks for asking. Response to quesiton2: As shown in https://github.com/ShannonAI/dice_loss_for_NLP/blob/418d09d285c103176152a97d73f8e7ebcdb1fa49/tasks/tnews/train.py#L139 we recommend using the following setting for multi-class tasks:
$ loss_fct = DiceLoss(square_denominator=True, with_logits=False, index_label_position=True,
smooth=1, ohem_ratio=0, alpha=0.01, reduction="none")
If input_probs = torch.FloatTensor([[0.9, 0.03, 0.03, 0.03],[0.03, 0.9, 0.03, 0.03]])
and target = torch.LongTensor([0, 1])
, then the dice loss should be :
$ loss_fct(input_probs, target)
> tensor([0.0079, 0.0079])
If input_probs = torch.FloatTensor([[0.9, 0.1, .0, .0],[.0, 0.9, 0.1, .0]])
and target = torch.LongTensor([0, 1])
, then the dice loss should be :
$ loss_fct(input_probs, target)
> tensor([0.0151, 0.0151])
These are in line with our expectations.
@xiaoya-li : Let me try it out, also can you recommend the settings for Multi-Label classification and NER task. NER Task:
inp = torch.FloatTensor([[[.1,.2,.3,.4]]*4,[[.5,.5,0,0]]*4]) #2 sentences, 4 words and 4 tags per word
target = torch.LongTensor([[0,1,1,2],[0,3,2,3]]) #tags 0,3, 2 sentences and 4 words
I have also met question 1, do you have any solution?@albertnanda
I have two part question,
Output tensor([1.9998, 1.9998], grad_fn=)