From 6419c7bdaa2acc5d4b92cdad1a05d56a63f23e0d Mon Sep 17 00:00:00 2001 From: WenmuZhou <572459439@qq.com> Date: Mon, 5 Sep 2022 15:31:19 +0800 Subject: [PATCH] add stop_gradient to create tensor --- ppocr/modeling/heads/table_att_head.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ppocr/modeling/heads/table_att_head.py b/ppocr/modeling/heads/table_att_head.py index 2e077124..d3c86e22 100644 --- a/ppocr/modeling/heads/table_att_head.py +++ b/ppocr/modeling/heads/table_att_head.py @@ -216,6 +216,8 @@ class SLAHead(nn.Layer): hidden = paddle.zeros((batch_size, self.hidden_size)) structure_preds = paddle.zeros((batch_size, self.max_text_length + 1, self.num_embeddings)) loc_preds = paddle.zeros((batch_size, self.max_text_length + 1, self.loc_reg_num)) + structure_preds.stop_gradient = True + loc_preds.stop_gradient = True if self.training and targets is not None: structure = targets[0] for i in range(self.max_text_length + 1): @@ -223,6 +225,7 @@ class SLAHead(nn.Layer): fea, hidden) structure_preds[:, i, :] = structure_step loc_preds[:, i, :] = loc_step + else: pre_chars = paddle.zeros(shape=[batch_size], dtype="int32") max_text_length = paddle.to_tensor(self.max_text_length) # for export -- GitLab