LayoutLM如何读取不同类型个数的checkpoints进行模型初始化 #13037
Unanswered
dinglei0719
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
我之前使用LayoutXLM在某个73类的SER任务上训练了模型,现在想用这个模型初始化,训练另一个21个类型的SER任务,但是在计算Loss时会提示维度不匹配,请问如何不适用原来checkpoint的输出层?
Traceback (most recent call last):
File "/ns_group/dinglei/ocr/code/PaddleOCR/tools/train.py", line 227, in
main(config, device, logger, vdl_writer)
File "/ns_group/dinglei/ocr/code/PaddleOCR/tools/train.py", line 198, in main
program.train(config, train_dataloader, valid_dataloader, device, model,
File "/ns_group/dinglei/ocr/code/PaddleOCR/tools/program.py", line 308, in train
loss = loss_class(preds, batch)
File "/ns_group/lihongyu/miniconda3/envs/paddle_39_dl/lib/python3.9/site-packages/paddle/nn/layer/layers.py", line 1254, in call
return self.forward(*inputs, **kwargs)
File "/ns_group/dinglei/ocr/code/PaddleOCR/ppocr/losses/vqa_token_layoutlm_loss.py", line 38, in forward
active_output = predicts.reshape(
File "/ns_group/lihongyu/miniconda3/envs/paddle_39_dl/lib/python3.9/site-packages/paddle/tensor/manipulation.py", line 3588, in reshape
out = _C_ops.reshape(x, new_shape)
ValueError: (InvalidArgument) The 'shape' attribute in ReshapeOp is invalid. The input tensor X'size must be divisible by known capacity of 'shape'. But received X's shape = [2, 512, 73], X's size = 74752, 'shape' is [-1, 21], known capacity of 'shape' is 21.
[Hint: Expected output_shape[unk_dim_idx] * capacity == in_size, but received output_shape[unk_dim_idx] * capacity:74739 != in_size:74752.] (at ../paddle/phi/infermeta/unary.cc:1762)
Beta Was this translation helpful? Give feedback.
All reactions