PaddleOCR icon indicating copy to clipboard operation
PaddleOCR copied to clipboard

Target is out of upper bound

Open guishilike opened this issue 2 years ago • 0 comments

kie ser训练出错

  • Window10
  • PaddleOCR 2.6
  File "H:/github/PaddleOCR/tools/train.py", line 202, in <module>
    main(config, device, logger, vdl_writer)
  File "H:/github/PaddleOCR/tools/train.py", line 175, in main
    program.train(config, train_dataloader, valid_dataloader, device, model,
  File "H:\github\PaddleOCR\tools\program.py", line 302, in train
    loss = loss_class(preds, batch)
  File "D:\anaconda3\envs\pytorch\lib\site-packages\paddle\fluid\dygraph\layers.py", line 930, in __call__
    return self._dygraph_call_func(*inputs, **kwargs)
  File "D:\anaconda3\envs\pytorch\lib\site-packages\paddle\fluid\dygraph\layers.py", line 915, in _dygraph_call_func
    outputs = self.forward(*inputs, **kwargs)
  File "H:\github\PaddleOCR\ppocr\losses\combined_loss.py", line 58, in forward
    loss = loss_func(input, batch, **kargs)
  File "D:\anaconda3\envs\pytorch\lib\site-packages\paddle\fluid\dygraph\layers.py", line 930, in __call__
    return self._dygraph_call_func(*inputs, **kwargs)
  File "D:\anaconda3\envs\pytorch\lib\site-packages\paddle\fluid\dygraph\layers.py", line 915, in _dygraph_call_func
    outputs = self.forward(*inputs, **kwargs)
  File "H:\github\PaddleOCR\ppocr\losses\distillation_loss.py", line 346, in forward
    loss = super().forward(out, batch)
  File "H:\github\PaddleOCR\ppocr\losses\vqa_token_layoutlm_loss.py", line 41, in forward
    loss = self.loss_class(active_output, active_label)
  File "D:\anaconda3\envs\pytorch\lib\site-packages\paddle\fluid\dygraph\layers.py", line 930, in __call__
    return self._dygraph_call_func(*inputs, **kwargs)
  File "D:\anaconda3\envs\pytorch\lib\site-packages\paddle\fluid\dygraph\layers.py", line 915, in _dygraph_call_func
    outputs = self.forward(*inputs, **kwargs)
  File "D:\anaconda3\envs\pytorch\lib\site-packages\paddle\nn\layer\loss.py", line 397, in forward
    ret = paddle.nn.functional.cross_entropy(
  File "D:\anaconda3\envs\pytorch\lib\site-packages\paddle\nn\functional\loss.py", line 1722, in cross_entropy
    raise ValueError("Target {} is out of upper bound.".format(
ValueError: Target 40 is out of upper bound.

部分配置如下:

Architecture:
  model_type: &model_type "kie"
  name: DistillationModel
  algorithm: Distillation
  Models:
    Teacher:
      pretrained:
      freeze_params: false
      return_all_feats: true
      model_type: *model_type
      algorithm: &algorithm "LayoutXLM"
      Transform:
      Backbone:
        name: LayoutXLMForSer
        pretrained: True
        # one of base or vi
        mode: vi
        checkpoints:
        num_classes: &num_classes 20
    Student:
      pretrained:
      freeze_params: false
      return_all_feats: true
      model_type: *model_type
      algorithm: *algorithm
      Transform:
      Backbone:
        name: LayoutXLMForSer
        pretrained: True
        # one of base or vi
        mode: vi
        checkpoints:
        num_classes: *num_classes

image

guishilike avatar Sep 23 '22 08:09 guishilike