1919import paddle
2020from paddle import base , in_dynamic_mode
2121from paddle .base .framework import in_dynamic_or_pir_mode
22- from paddle .nn .layer .utils import check_deprecated_params
23- from paddle .utils .decorator_utils import ParamAliasDecorator
22+ from paddle .utils .decorator_utils import (
23+ ParamAliasDecorator ,
24+ check_deprecated_params_on_init ,
25+ )
2426
2527from .. import functional as F
2628from .layers import Layer
3739__all__ = []
3840
3941
40- @check_deprecated_params
4142class BCEWithLogitsLoss (Layer ):
4243 r"""
4344
@@ -122,6 +123,7 @@ class BCEWithLogitsLoss(Layer):
122123 pos_weight : Tensor | None
123124 name : str | None
124125
126+ @check_deprecated_params_on_init
125127 def __init__ (
126128 self ,
127129 weight : Tensor | None = None ,
@@ -153,7 +155,6 @@ def forward(self, logit: Tensor, label: Tensor) -> Tensor:
153155 return out
154156
155157
156- @check_deprecated_params
157158class CrossEntropyLoss (Layer ):
158159 r"""
159160
@@ -420,6 +421,7 @@ class CrossEntropyLoss(Layer):
420421 label_smoothing : float
421422 name : str | None
422423
424+ @check_deprecated_params_on_init
423425 def __init__ (
424426 self ,
425427 weight : Tensor | None = None ,
@@ -606,7 +608,6 @@ def forward(
606608 return out
607609
608610
609- @check_deprecated_params
610611class MSELoss (Layer ):
611612 r"""
612613 **Mean Square Error Loss**
@@ -659,6 +660,7 @@ class MSELoss(Layer):
659660
660661 reduction : _ReduceMode
661662
663+ @check_deprecated_params_on_init
662664 def __init__ (self , reduction : _ReduceMode = 'mean' ):
663665 super ().__init__ ()
664666 if reduction not in ['sum' , 'mean' , 'none' ]:
@@ -692,7 +694,6 @@ def forward(self, input: Tensor, label: Tensor) -> Tensor:
692694 return paddle .mean (square_out )
693695
694696
695- @check_deprecated_params
696697class L1Loss (Layer ):
697698 r"""
698699
@@ -763,6 +764,7 @@ class L1Loss(Layer):
763764 reduction : _ReduceMode
764765 name : str | None
765766
767+ @check_deprecated_params_on_init
766768 def __init__ (
767769 self , reduction : _ReduceMode = 'mean' , name : str | None = None
768770 ) -> None :
@@ -781,7 +783,6 @@ def forward(self, input: Tensor, label: Tensor) -> Tensor:
781783 )
782784
783785
784- @check_deprecated_params
785786class BCELoss (Layer ):
786787 """
787788
@@ -854,6 +855,7 @@ class BCELoss(Layer):
854855 reduction : _ReduceMode
855856 name : str | None
856857
858+ @check_deprecated_params_on_init
857859 def __init__ (
858860 self ,
859861 weight : Tensor | None = None ,
@@ -878,7 +880,6 @@ def forward(self, input: Tensor, label: Tensor) -> Tensor:
878880 return out
879881
880882
881- @check_deprecated_params
882883class NLLLoss (Layer ):
883884 r"""
884885
@@ -967,6 +968,7 @@ class NLLLoss(Layer):
967968
968969 """
969970
971+ @check_deprecated_params_on_init
970972 def __init__ (
971973 self ,
972974 weight : Tensor | None = None ,
@@ -996,7 +998,6 @@ def forward(self, input: Tensor, label: Tensor) -> Tensor:
996998 )
997999
9981000
999- @check_deprecated_params
10001001class PoissonNLLLoss (Layer ):
10011002 r"""Generate a callable object of 'PoissonNLLLoss' to calculate the
10021003 Poisson negative log likelihood loss between Input(input) and
@@ -1056,6 +1057,7 @@ class PoissonNLLLoss(Layer):
10561057
10571058 """
10581059
1060+ @check_deprecated_params_on_init
10591061 def __init__ (
10601062 self ,
10611063 log_input : bool = True ,
@@ -1092,7 +1094,6 @@ def forward(self, input: Tensor, label: Tensor) -> Tensor:
10921094 )
10931095
10941096
1095- @check_deprecated_params
10961097class KLDivLoss (Layer ):
10971098 r"""
10981099
@@ -1188,6 +1189,7 @@ class KLDivLoss(Layer):
11881189 reduction : _ReduceMode
11891190 log_target : bool
11901191
1192+ @check_deprecated_params_on_init
11911193 def __init__ (
11921194 self , reduction : _ReduceMode = 'mean' , log_target : bool = False
11931195 ) -> None :
@@ -1200,7 +1202,6 @@ def forward(self, input: Tensor, label: Tensor) -> Tensor:
12001202 return out
12011203
12021204
1203- @check_deprecated_params
12041205class MarginRankingLoss (Layer ):
12051206 r"""
12061207
@@ -1261,6 +1262,7 @@ class MarginRankingLoss(Layer):
12611262 reduction : _ReduceMode
12621263 name : str | None
12631264
1265+ @check_deprecated_params_on_init
12641266 def __init__ (
12651267 self ,
12661268 margin : float = 0.0 ,
@@ -1470,7 +1472,6 @@ def forward(
14701472 )
14711473
14721474
1473- @check_deprecated_params
14741475class SmoothL1Loss (Layer ):
14751476 r"""
14761477 This operator calculates smooth_l1_loss. Creates a criterion that uses a squared
@@ -1535,6 +1536,7 @@ class SmoothL1Loss(Layer):
15351536 delta : float
15361537 name : str | None
15371538
1539+ @check_deprecated_params_on_init
15381540 def __init__ (
15391541 self ,
15401542 reduction : _ReduceMode = 'mean' ,
@@ -1559,7 +1561,6 @@ def forward(self, input: Tensor, label: Tensor) -> Tensor:
15591561 )
15601562
15611563
1562- @check_deprecated_params
15631564class MultiLabelSoftMarginLoss (Layer ):
15641565 r"""Creates a criterion that optimizes a multi-class multi-classification
15651566 hinge loss (margin-based loss) between input :math:`x` (a 2D mini-batch `Tensor`)
@@ -1624,6 +1625,7 @@ class MultiLabelSoftMarginLoss(Layer):
16241625 reduction : _ReduceMode
16251626 name : str | None
16261627
1628+ @check_deprecated_params_on_init
16271629 def __init__ (
16281630 self ,
16291631 weight : Tensor | None = None ,
@@ -1650,7 +1652,6 @@ def forward(self, input: Tensor, label: Tensor) -> Tensor:
16501652 )
16511653
16521654
1653- @check_deprecated_params
16541655class HingeEmbeddingLoss (Layer ):
16551656 r"""
16561657 Create a callable object of `HingeEmbeddingLoss` to calculates hinge_embedding_loss. Measures the loss given an input tensor :math:`x` and a labels tensor :math:`y`(containing 1 or -1).
@@ -1737,6 +1738,7 @@ class HingeEmbeddingLoss(Layer):
17371738 reduction : _ReduceMode
17381739 name : str | None
17391740
1741+ @check_deprecated_params_on_init
17401742 def __init__ (
17411743 self ,
17421744 margin : float = 1.0 ,
@@ -1758,7 +1760,6 @@ def forward(self, input: Tensor, label: Tensor) -> Tensor:
17581760 )
17591761
17601762
1761- @check_deprecated_params
17621763class CosineEmbeddingLoss (Layer ):
17631764 r"""
17641765 This interface is used to construct a callable object of the ``CosineEmbeddingLoss`` class.
@@ -1836,6 +1837,7 @@ class CosineEmbeddingLoss(Layer):
18361837 reduction : _ReduceMode
18371838 name : str | None
18381839
1840+ @check_deprecated_params_on_init
18391841 def __init__ (
18401842 self ,
18411843 margin : float = 0 ,
@@ -1989,7 +1991,6 @@ def forward(
19891991 )
19901992
19911993
1992- @check_deprecated_params
19931994class TripletMarginLoss (Layer ):
19941995 r"""
19951996 Creates a criterion that measures the triplet loss given an input
@@ -2074,6 +2075,7 @@ class TripletMarginLoss(Layer):
20742075 reduction : _ReduceMode
20752076 name : str | None
20762077
2078+ @check_deprecated_params_on_init
20772079 def __init__ (
20782080 self ,
20792081 margin : float = 1.0 ,
@@ -2112,7 +2114,6 @@ def forward(
21122114 )
21132115
21142116
2115- @check_deprecated_params
21162117class MultiMarginLoss (Layer ):
21172118 r"""Creates a criterion that optimizes a multi-class classification hinge loss (margin-based loss) between
21182119 input :math:`input` and label :math:`label`:
@@ -2191,6 +2192,7 @@ class MultiMarginLoss(Layer):
21912192 reduction : _ReduceMode
21922193 name : str | None
21932194
2195+ @check_deprecated_params_on_init
21942196 def __init__ (
21952197 self ,
21962198 p : int = 1 ,
@@ -2223,7 +2225,6 @@ def forward(self, input: Tensor, label: Tensor) -> Tensor:
22232225 )
22242226
22252227
2226- @check_deprecated_params
22272228class MultiLabelMarginLoss (Layer ):
22282229 r"""Creates a criterion that optimizes a multi-class multi-classification hinge loss (margin-based loss)
22292230 between input :math:`input` and label :math:`label`:
@@ -2287,6 +2288,7 @@ class MultiLabelMarginLoss(Layer):
22872288 reduction : _ReduceMode
22882289 name : str | None
22892290
2291+ @check_deprecated_params_on_init
22902292 def __init__ (
22912293 self ,
22922294 reduction : _ReduceMode = 'mean' ,
@@ -2310,7 +2312,6 @@ def forward(self, input: Tensor, label: Tensor) -> Tensor:
23102312 )
23112313
23122314
2313- @check_deprecated_params
23142315class SoftMarginLoss (Layer ):
23152316 r"""
23162317
@@ -2376,6 +2377,7 @@ class SoftMarginLoss(Layer):
23762377 reduction : _ReduceMode
23772378 name : str | None
23782379
2380+ @check_deprecated_params_on_init
23792381 def __init__ (
23802382 self , reduction : _ReduceMode = 'mean' , name : str | None = None
23812383 ) -> None :
0 commit comments