From 9ecfc34809cd4cb8a428a926612138db1b688854 Mon Sep 17 00:00:00 2001 From: WenmuZhou <572459439@qq.com> Date: Wed, 5 Jan 2022 14:49:04 +0000 Subject: [PATCH] rm const decay --- configs/vqa/re/layoutxlm.yml | 2 +- configs/vqa/ser/layoutlm.yml | 2 +- configs/vqa/ser/layoutxlm.yml | 2 +- ppocr/optimizer/regularizer.py | 26 +++++--------------------- 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/configs/vqa/re/layoutxlm.yml b/configs/vqa/re/layoutxlm.yml index bb367f0e..8d0ffadf 100644 --- a/configs/vqa/re/layoutxlm.yml +++ b/configs/vqa/re/layoutxlm.yml @@ -36,7 +36,7 @@ Optimizer: lr: learning_rate: 0.00005 regularizer: - name: Const + name: L2 factor: 0.00000 PostProcess: diff --git a/configs/vqa/ser/layoutlm.yml b/configs/vqa/ser/layoutlm.yml index a635fc7d..f29153a2 100644 --- a/configs/vqa/ser/layoutlm.yml +++ b/configs/vqa/ser/layoutlm.yml @@ -38,7 +38,7 @@ Optimizer: epochs: *epoch_num warmup_epoch: 2 regularizer: - name: Const + name: L2 factor: 0.00000 PostProcess: diff --git a/configs/vqa/ser/layoutxlm.yml b/configs/vqa/ser/layoutxlm.yml index 1c1eac22..14041eb2 100644 --- a/configs/vqa/ser/layoutxlm.yml +++ b/configs/vqa/ser/layoutxlm.yml @@ -38,7 +38,7 @@ Optimizer: epochs: *epoch_num warmup_epoch: 2 regularizer: - name: Const + name: L2 factor: 0.00000 PostProcess: diff --git a/ppocr/optimizer/regularizer.py b/ppocr/optimizer/regularizer.py index 83010e65..d48831fc 100644 --- a/ppocr/optimizer/regularizer.py +++ b/ppocr/optimizer/regularizer.py @@ -29,39 +29,23 @@ class L1Decay(object): def __init__(self, factor=0.0): super(L1Decay, self).__init__() - self.regularization_coeff = factor + self.coeff = factor def __call__(self): - reg = paddle.regularizer.L1Decay(self.regularization_coeff) + reg = paddle.regularizer.L1Decay(self.coeff) return reg class L2Decay(object): """ - L2 Weight Decay Regularization, which encourages the weights to be sparse. + L2 Weight Decay Regularization, which helps to prevent the model over-fitting. Args: factor(float): regularization coeff. Default:0.0. """ def __init__(self, factor=0.0): super(L2Decay, self).__init__() - self.regularization_coeff = factor + self.coeff = factor def __call__(self): - reg = paddle.regularizer.L2Decay(self.regularization_coeff) - return reg - - -class ConstDecay(object): - """ - Const L2 Weight Decay Regularization, which encourages the weights to be sparse. - Args: - factor(float): regularization coeff. Default:0.0. - """ - - def __init__(self, factor=0.0): - super(ConstDecay, self).__init__() - self.regularization_coeff = factor - - def __call__(self): - return self.regularization_coeff + return self.coeff \ No newline at end of file -- GitLab