From a5d46d3d19128ec3cb8931eeee7c41a1894c6223 Mon Sep 17 00:00:00 2001 From: Wenyu Date: Thu, 23 Sep 2021 10:52:50 +0800 Subject: [PATCH] update bias init (#4213) --- ppdet/modeling/heads/detr_head.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ppdet/modeling/heads/detr_head.py b/ppdet/modeling/heads/detr_head.py index 303e814d9..8f4b4ebbf 100644 --- a/ppdet/modeling/heads/detr_head.py +++ b/ppdet/modeling/heads/detr_head.py @@ -307,9 +307,11 @@ class DeformableDETRHead(nn.Layer): linear_init_(self.score_head) constant_(self.score_head.bias, -4.595) constant_(self.bbox_head.layers[-1].weight) - bias = paddle.zeros_like(self.bbox_head.layers[-1].bias) - bias[2:] = -2.0 - self.bbox_head.layers[-1].bias.set_value(bias) + + with paddle.no_grad(): + bias = paddle.zeros_like(self.bbox_head.layers[-1].bias) + bias[2:] = -2.0 + self.bbox_head.layers[-1].bias.set_value(bias) @classmethod def from_config(cls, cfg, hidden_dim, nhead, input_shape): -- GitLab