diff --git a/ppcls/arch/gears/metabnneck.py b/ppcls/arch/gears/metabnneck.py index 7dd78cd8294758d0576f00cf33a1530317504281..d2f743da6f832f03fb51eee8b59bc9c759f509af 100644 --- a/ppcls/arch/gears/metabnneck.py +++ b/ppcls/arch/gears/metabnneck.py @@ -22,7 +22,7 @@ import paddle.nn.functional as F from ..utils import get_param_attr_dict -class MetaBN1D(nn.BatchNorm2D): +class MetaBN1D(nn.BatchNorm1D): def forward(self, inputs, opt={}): mode = opt.get("bn_mode", "general") if self.training else "eval" if mode == "general": # update, but not apply running_mean/var diff --git a/ppcls/engine/train/train_metabin.py b/ppcls/engine/train/train_metabin.py index 21a4a7863f186e06bbbd2ab34ff91de0c5dffc5a..b4994b699b55b182178684601b04de7c43d966d8 100644 --- a/ppcls/engine/train/train_metabin.py +++ b/ppcls/engine/train/train_metabin.py @@ -141,15 +141,15 @@ def setup_opt(engine, stage): opt["bn_mode"] = "hold" opt["enable_inside_update"] = True opt["lr_gate"] = norm_lr * cyclic_lr - for name, layer in engine.model.backbone.named_sublayers(): - if "bn" == name.split('.')[-1]: + for layer in engine.model.backbone.sublayers(): + if type_name(layer) == "MetaBIN": layer.setup_opt(opt) engine.model.neck.setup_opt(opt) def reset_opt(model): - for name, layer in model.backbone.named_sublayers(): - if "bn" == name.split('.')[-1]: + for layer in model.backbone.sublayers(): + if type_name(layer) == "MetaBIN": layer.reset_opt() model.neck.reset_opt()