From 48417da3861dfd74684ad72a9c21523338ba4c4b Mon Sep 17 00:00:00 2001 From: Wenyu Date: Fri, 6 May 2022 10:10:12 +0800 Subject: [PATCH] fix freeze (#5883) --- ppdet/modeling/backbones/swin_transformer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ppdet/modeling/backbones/swin_transformer.py b/ppdet/modeling/backbones/swin_transformer.py index 8509b5164..bd541784e 100644 --- a/ppdet/modeling/backbones/swin_transformer.py +++ b/ppdet/modeling/backbones/swin_transformer.py @@ -688,10 +688,10 @@ class SwinTransformer(nn.Layer): if self.frozen_stages >= 0: self.patch_embed.eval() for param in self.patch_embed.parameters(): - param.requires_grad = False + param.stop_gradient = True if self.frozen_stages >= 1 and self.ape: - self.absolute_pos_embed.requires_grad = False + self.absolute_pos_embed.stop_gradient = True if self.frozen_stages >= 2: self.pos_drop.eval() @@ -699,7 +699,7 @@ class SwinTransformer(nn.Layer): m = self.layers[i] m.eval() for param in m.parameters(): - param.requires_grad = False + param.stop_gradient = True def _init_weights(self, m): if isinstance(m, nn.Linear): -- GitLab