Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIE训练学生模型报错 #3233

Closed
YYGe01 opened this issue Sep 9, 2022 · 2 comments
Closed

UIE训练学生模型报错 #3233

YYGe01 opened this issue Sep 9, 2022 · 2 comments
Assignees

Comments

@YYGe01
Copy link

YYGe01 commented Sep 9, 2022

  • 版本、环境信息
    1)PaddleNLP和PaddlePaddle版本:PaddleNLP 2.4.0,PaddlePaddle2.3.1
    2)系统环境:Windows,python3.8
  • 复现信息:
python train.py \
    --task_type relation_extraction \
    --train_path student_data/train_data.json \
    --dev_path student_data/dev_data.json \
    --label_maps_path student_data/label_maps.json \
    --num_epochs 200 \
    --encoder ernie-3.0-mini-zh

报错:

Traceback (most recent call last):
  File "C:/Users/49476/glory/work/docparser/DesignDocParser/src/uie/data_distill/train.py", line 194, in <module>
    do_train()
  File "C:/Users/49476/glory/work/docparser/DesignDocParser/src/uie/data_distill/train.py", line 110, in do_train
    loss = sum([criterion(o, l) for o, l in zip(logits, labels)]) / 3
  File "C:/Users/49476/glory/work/docparser/DesignDocParser/src/uie/data_distill/train.py", line 110, in <listcomp>
    loss = sum([criterion(o, l) for o, l in zip(logits, labels)]) / 3
  File "C:\Users\49476\glory\work\docparser\DesignDocParser\src\uie\data_distill\criterion.py", line 59, in __call__
    loss = self._sparse_multilabel_categorical_crossentropy(
  File "C:\Users\49476\glory\work\docparser\DesignDocParser\src\uie\data_distill\criterion.py", line 38, in _sparse_multilabel_categorical_crossentropy
    y_pos_2 = paddle.take_along_axis(y_pred, y_true, axis=-1)
  File "C:\Users\49476\anaconda3\envs\uie\lib\site-packages\paddle\tensor\manipulation.py", line 2854, in take_along_axis
    indices = paddle.broadcast_to(indices, broadcast_shape)
  File "C:\Users\49476\anaconda3\envs\uie\lib\site-packages\paddle\tensor\manipulation.py", line 1917, in broadcast_to
    return _C_ops.expand_v2(x, 'shape', shape)
ValueError: (InvalidArgument) The 2th element of 'shape' for expand_v2 op must be greater than 0, but the value given is 0.
  [Hint: Expected expand_shape[i] > 0, but received expand_shape[i]:0 <= 0:0.] (at ..\paddle\phi\infermeta\unary.cc:511)
  [operator < expand_v2 > error]

经排查发现是labels的第三个维度是零的问题,但某个样本里没有有效信息,是允许的,希望特别处理下这种情况,谢谢。
image
image

@dingidng
Copy link

参考下面项目,在AIstudio已经跑通
UIE Slim满足工业应用场景,解决推理部署耗时问题,提升效能!
https://aistudio.baidu.com/aistudio/projectdetail/4516470?contributionType=1

@YYGe01 YYGe01 closed this as completed Sep 15, 2022
@Ecust-ylw
Copy link

你好,这个问题后来解决了吗?我也遇到这个问题了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants