thunlp / PL-Marker

Source code for "Packed Levitated Marker for Entity and Relation Extraction"
MIT License
260 stars 35 forks source link

CrossEntropyLoss weight #48

Closed kizunasunhy closed 1 year ago

kizunasunhy commented 1 year ago

Hello just a little question. I saw you almost implemented weighted CrossEntropyLoss for all models as this:

loss_fct_re = CrossEntropyLoss(ignore_index=-1,  weight=self.alpha.to(re_prediction_scores))

So here self.alpha = tensor([1., 1., 1., ..., 1., 1.] where the length equals to the number of classes. But after self.alpha.to(re_prediction_scores), actually it is still self.alpha, where all the elements are 1. So seems like the weighted CrossEntropyLoss doesn't have it's effect. Did I make it wrong?

YeDeming commented 1 year ago

You're right. You can just remove weight=self.alpha.to(re_prediction_scores)