背景:

今天使用bert finetuning的方式进行文本多分类任务时候,遇到一个报错,记录一下

tensorflow.python.framework.errors_impl.InvalidArgumentError: Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint.

tensorflow.python.framework.errors_impl.InvalidArgumentError: Restoring from checkpoint failed. This

操作过程

采用数据1,其中为20分类的数据, 训练模型的过程中,

数据为 label (\t)text 格式

label为0,1,2,3,。。。20的格式

处理过程中label为string类型,csv中自带了"字符,导致有的label为2,有的为 "2 导致label个数变多

 

修改完后,采用数据2,三分类数据训练过程就报错

最后发现output的checkpoint中有数据的问题,导致出现了shape不一致的情况,上次运行20分类任务的时候生成的模型和现在生成的三分类模型的shape不一致,所以这里需要在运行前先清空之情的output。

        --output_dir=/tmp/mrpc_output/

rm -rf /tmp/mrpc_output/

或者手动删除改文件夹

 

 

相关文章:

  • 2022-12-23
  • 2022-03-06
  • 2021-10-20
  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-06
  • 2021-07-03
  • 2022-02-20
  • 2021-11-24
  • 2021-12-09
  • 2021-05-28
  • 2022-12-23
相关资源
相似解决方案