Skip to content

Commit

Permalink
rename loss
Browse files Browse the repository at this point in the history
  • Loading branch information
liuhongen1234567 committed Dec 20, 2024
1 parent 165ca3a commit 72d90d7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion configs/rec/PP-FormuaNet/rec_pp_formulanet_l.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Architecture:
parallel_step: 0

Loss:
name: PPFormulaNet_L
name: PPFormulaNet_L_Loss

PostProcess:
name: UniMERNetDecode
Expand Down
2 changes: 1 addition & 1 deletion configs/rec/PP-FormuaNet/rec_pp_formulanet_s.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Architecture:
parallel_step: 3

Loss:
name: PPFormulaNet_S
name: PPFormulaNet_S_Loss
parallel_step: 3

PostProcess:
Expand Down
6 changes: 3 additions & 3 deletions ppocr/losses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from .rec_cppd_loss import CPPDLoss
from .rec_latexocr_loss import LaTeXOCRLoss
from .rec_unimernet_loss import UniMERNetLoss
from .rec_ppformulanet_loss import PPFormulaNet_S, PPFormulaNet_L
from .rec_ppformulanet_loss import PPFormulaNet_S_Loss, PPFormulaNet_L_Loss

# cls loss
from .cls_loss import ClsLoss
Expand Down Expand Up @@ -112,8 +112,8 @@ def build_loss(config):
"CPPDLoss",
"LaTeXOCRLoss",
"UniMERNetLoss",
"PPFormulaNet_S",
"PPFormulaNet_L",
"PPFormulaNet_S_Loss",
"PPFormulaNet_L_Loss",
]
config = copy.deepcopy(config)
module_name = config.pop("name")
Expand Down
8 changes: 4 additions & 4 deletions ppocr/losses/rec_ppformulanet_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
import paddle.nn as nn


class PPFormulaNet_S(nn.Layer):
class PPFormulaNet_S_Loss(nn.Layer):
"""
PP=FormulaNet-S adopt CrossEntropyLoss for network training.
"""

def __init__(self, vocab_size=50000, parallel_step=1):
super(PPFormulaNet_S, self).__init__()
super(PPFormulaNet_S_Loss, self).__init__()
self.ignore_index = -100
self.vocab_size = vocab_size
self.parallel_step = int(parallel_step)
Expand All @@ -44,13 +44,13 @@ def forward(self, preds, batch):
}


class PPFormulaNet_L(nn.Layer):
class PPFormulaNet_L_Loss(nn.Layer):
"""
PPFormulaNet_L adopt CrossEntropyLoss for network training.
"""

def __init__(self, vocab_size=50000):
super(PPFormulaNet_L, self).__init__()
super(PPFormulaNet_L_Loss, self).__init__()
self.ignore_index = -100
self.vocab_size = vocab_size
self.pad_token_id = 1
Expand Down

0 comments on commit 72d90d7

Please sign in to comment.