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

背景:

今天使用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/

或者手动删除改文件夹

 

 

Related Posts

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注