From a6ab34fd384081fae06d18c5759eeeac682f73fa Mon Sep 17 00:00:00 2001 From: yunfan Date: Sat, 10 Nov 2018 12:31:57 +0800 Subject: [PATCH] fix crf --- fastNLP/modules/decoder/CRF.py | 2 +- reproduction/Biaffine_parser/run.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fastNLP/modules/decoder/CRF.py b/fastNLP/modules/decoder/CRF.py index cd68d35d..11cde48a 100644 --- a/fastNLP/modules/decoder/CRF.py +++ b/fastNLP/modules/decoder/CRF.py @@ -89,7 +89,7 @@ class ConditionalRandomField(nn.Module): score = score.sum(0) + emit_score[-1] if self.include_start_end_trans: st_scores = self.start_scores.view(1, -1).repeat(batch_size, 1)[batch_idx, tags[0]] - last_idx = masks.long().sum(0) + last_idx = mask.long().sum(0) ed_scores = self.end_scores.view(1, -1).repeat(batch_size, 1)[batch_idx, tags[last_idx, batch_idx]] score += st_scores + ed_scores # return [B,] diff --git a/reproduction/Biaffine_parser/run.py b/reproduction/Biaffine_parser/run.py index 45668066..209e45cb 100644 --- a/reproduction/Biaffine_parser/run.py +++ b/reproduction/Biaffine_parser/run.py @@ -352,7 +352,7 @@ if __name__ == "__main__": elif args.mode == 'test': test(args.path) elif args.mode == 'infer': - infer() + pass else: print('no mode specified for model!') parser.print_help()