简体   繁体   English

收到警告:您可能应该在下游任务中训练此模型,以便能够将其用于预测和推理。 加载微调模型时

[英]Get warning : You should probably TRAIN this model on a downstream task to be able to use it for predictions and inference. when loadin finetune model

I get this message when loading a finetune model of Bert with a forward neural netword on the last layer from a checkpoint directory.当从检查点目录的最后一层加载带有前向神经网络的 Bert 微调模型时,我收到此消息。

 This IS expected if you are initializing FlaubertForSequenceClassification fr            om the checkpoint of a model trained on another task or with another architectu            re (e.g. initializing a BertForSequenceClassification model from a BertForPreTr            aining model).
- This IS NOT expected if you are initializing FlaubertForSequenceClassificatio            n from the checkpoint of a model that you expect to be exactly identical (initi            alizing a BertForSequenceClassification model from a BertForSequenceClassificat            ion model).
Some weights of FlaubertForSequenceClassification were not initialized from the             model checkpoint at /gpfswork/rech/kpf/umg16uw/results_hf/sm/checkpoint-10 and             are newly initialized: ['sequence_summary.summary.weight', 'sequence_summary.s            ummary.bias']
You should probably TRAIN this model on a down-stream task to be able to use it             for predictions and inference.


Actually the model already trained on a huge dataset and I loaded it to perform inference on new dataset.实际上,该模型已经在一个巨大的数据集上进行了训练,我加载它以对新数据集进行推理。


model = XXXForSequenceClassification.from_pretrained(modelForClass, num_labels=3)

test_file = '/g/012.xml'
modelForClass = '/g/checkpoint-10'
    
test = preprare_data(PRE_TRAINED_MODEL_NAME, test_file)
pred = predict(test, test_model)

***** Running Prediction *****
  Num examples = 5
  Batch size = 8
  0%|                                                    | 0/1 [00:00<?, ?it/s][[-0.0903191   0.18442413 -0.09337573]
 [-0.08772105  0.17791435 -0.10178708]
 [-0.0903393   0.18614864 -0.08101001]
 [-0.08786416  0.1888753  -0.08145989]
 [-0.06697702  0.1874733  -0.09423935]]
100%|████████████████████████████████████████████| 1/1 [00:00<00:00,  9.89it/s]

real    0m36.431s

not sure if this help, but I got the same error when loading an existing model using the transformers library from HuggingFace.不确定这是否有帮助,但我在使用 HuggingFace 的变形金刚库加载现有模型时遇到了同样的错误。 I fixed my error by initialising the proper library (ie I was using Tensorflow when I should have been using Pytorch) and then was able to read the model.我通过初始化正确的库修复了我的错误(即当我应该使用 Pytorch 时我使用了 Tensorflow)然后能够读取模型。 The model I was using was trained using Roberta.我使用的模型是使用 Roberta 训练的。 However, I changed the model with one using a regular Bert model.但是,我将模型更改为使用常规 Bert 模型的模型。 I hope this helps or maybe points you in the right direction.我希望这对您有所帮助,或者可能会为您指明正确的方向。 If possible, could I see the complete code?如果可能的话,我可以看到完整的代码吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的 tensorflow Roberta Model 无法训练/微调? - Why is my tensorflow Roberta Model unable to train/finetune? 无法在 Windows 上训练 Deepspeech model - Not able to train the Deepspeech model on Windows 当使用预训练模型(vgg、re.net like)作为主干时,我们应该在“eval mode”还是“train mode”中使用它? - When using pretrained model(vgg, resnet like) as backbone, should we use it in `eval mode` or in `train mode`? 在 pytorch 中重新训练 model 时,是否应该在训练方法之外定义优化器? 如果没有,它会摆脱以前的权重吗? - When retraining a model in pytorch should the optimizer be defined outside the train method? Will it get rid of previous weights if not? 用一个任务训练一个 model 并用另一个任务测试它? - Train a model with a task and test it with another task? inverseTransform 是否应该是模型进行预测的静态方法 - Should inverseTransform be a static method for a model making predictions Model 在训练和验证中获得 97% 的准确率,但是当使用自定义预测时它会出错 - Model get 97% accuracy on train and validation but when use custom predict it get wrong Pytorch NLP 模型在进行推理时不使用 GPU - Pytorch NLP model doesn’t use GPU when making inference 训练 fc 层后 Finetune PyTorch 模型 - Finetune PyTorch model after training fc layers 在优化器上使用tf.group后如何从tensorflow模型中获取预测 - How to get predictions out of tensorflow model after you've used tf.group on your optimizers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM