Skip to content

Commit

Permalink
fix attn loss for ce
Browse files Browse the repository at this point in the history
  • Loading branch information
tink2123 committed Nov 22, 2021
1 parent 8b3b787 commit 477eb58
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ppocr/data/imaug/label_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def __call__(self, data):
text = self.encode(text)
if text is None:
return None
if len(text) >= self.max_text_len:
if len(text) >= self.max_text_len - 1:
return None
data['length'] = np.array(len(text))
text = [0] + text + [len(self.character) - 1] + [0] * (self.max_text_len
Expand Down
1 change: 1 addition & 0 deletions ppocr/modeling/heads/rec_att_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def forward(self, inputs, targets=None, batch_max_length=25):
probs_step, axis=1)], axis=1)
next_input = probs_step.argmax(axis=1)
targets = next_input
if not self.training:
probs = paddle.nn.functional.softmax(probs, axis=2)
return probs

Expand Down

0 comments on commit 477eb58

Please sign in to comment.