PaddlePaddle / PaddleNLP

👑 Easy-to-use and powerful NLP and LLM library with 🤗 Awesome model zoo, supporting wide-range of NLP tasks from research to industrial applications, including 🗂Text Classification, 🔍 Neural Search, ❓ Question Answering, ℹ️ Information Extraction, 📄 Document Intelligence, 💌 Sentiment Analysis etc.
https://paddlenlp.readthedocs.io
Apache License 2.0
12.17k stars 2.94k forks source link

[Bug]: 调用relation识别时报错AttributeError: 'bool' object has no attribute 'sum' #7841

Closed lixiang1991 closed 6 months ago

lixiang1991 commented 10 months ago

软件环境

- paddlepaddle:
- paddlepaddle-gpu: 2.6.0.post120
- paddlenlp: 2.6.1

重复问题

错误描述

negative_mask.sum()就报AttributeError: 'bool' object has no attribute 'sum'

稳定复现步骤 & 代码

7840 https://github.com/PaddlePaddle/PaddleNLP/commit/2560f2da0202a2985a142a327107edb9580cf3aa#diff-2742b8e7477bc6c550f7ac3a94fe8bbe2f3726eef2b56cdac75d187e9f9a44fc

不清楚这里为什么要把==改成is,在用paddleocr中的infer_kie_token_ser_re.py时,调用了paddlenlp2.6.1中的re,运行到 if negative_mask.sum() > 0: 我的python版本是3.9。 negative_mask = paddle.any(mask, axis=1) is False的结果就是negative_mask=False,然后下面的negative_mask.sum()就报bool没有sum方法的错。 我自己把is改成==就正常了

BB86818BB commented 8 months ago

我做re训练的时候同样遇到了这个错误 ,我按照你介绍的方式把is改成==,但是在训练完成后进行预测的时候报错了,信息如下:Traceback (most recent call last): File "/home/ocr/PaddleOCR-release-2.7.1/./tools/infer_kie_token_ser_re.py", line 218, in result = ser_re_engine(data) File "/home/ocr/PaddleOCR-release-2.7.1/./tools/infer_kie_token_ser_re.py", line 152, in call preds = self.model(re_input) File "/usr/local/lib/python3.10/site-packages/paddle/nn/layer/layers.py", line 1429, in call return self.forward(*inputs, kwargs) File "/home/ocr/PaddleOCR-release-2.7.1/ppocr/modeling/architectures/base_model.py", line 86, in forward x = self.backbone(x) File "/usr/local/lib/python3.10/site-packages/paddle/nn/layer/layers.py", line 1429, in call return self.forward(*inputs, *kwargs) File "/home/ocr/PaddleOCR-release-2.7.1/ppocr/modeling/backbones/vqa_layoutlm.py", line 220, in forward x = self.model( File "/usr/local/lib/python3.10/site-packages/paddle/nn/layer/layers.py", line 1429, in call return self.forward(inputs, kwargs) File "/usr/local/lib/python3.10/site-packages/paddlenlp/transformers/layoutxlm/modeling.py", line 1329, in forward loss, pred_relations = self.extractor(sequence_output, entities, relations) File "/usr/local/lib/python3.10/site-packages/paddle/nn/layer/layers.py", line 1429, in call return self.forward(*inputs, **kwargs) File "/usr/local/lib/python3.10/site-packages/paddlenlp/transformers/layoutxlm/modeling.py", line 1223, in forward relations, entities = self.build_relation(relations, entities) File "/usr/local/lib/python3.10/site-packages/paddlenlp/transformers/layoutxlm/modeling.py", line 1167, in build_relation all_possible_relations = paddle.stack( File "/usr/local/lib/python3.10/site-packages/paddle/tensor/manipulation.py", line 2001, in stack return _C_ops.stack(x, axis) ValueError: (InvalidArgument) x dim number should greater than 0, but received value is: 0 [Hint: Expected x_dim > 0, but received x_dim:0 <= 0:0.] (at ../paddle/phi/backends/gpu/gpu_launch_config.h:166)

请问你那有没有出现这个问题?

github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 60 days with no activity. 当前issue 60天内无活动,被标记为stale。

github-actions[bot] commented 6 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale. 当前issue 被标记为stale已有14天,即将关闭。