xmxoxo / BERT-train2deploy

BERT模型从训练到部署
517 stars 165 forks source link

我的是英文NER的BERT模型,东西大同小异,但是我在用freeze_.graph.py的时候出现了如下问题,想请教下您会吗 #21

Open zwd13122889 opened 4 years ago

zwd13122889 commented 4 years ago

tensorflow.python.framework.errors_impl.NotFoundError: Restoring from checkpoint failed. This is most likely due to a Variable name or other graph key that is missing from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

Key output_bias not found in checkpoint [[node save/RestoreV2 (defined at freeze_graph.py:191) = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, ..., DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]] [[{{node save/RestoreV2/_393}} = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_397_save/RestoreV2", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]

然后我打开了checkpoint的文件,文件如下: model_checkpoint_path: "model.ckpt-1136" all_model_checkpoint_paths: "model.ckpt-0" all_model_checkpoint_paths: "model.ckpt-1000" all_model_checkpoint_paths: "model.ckpt-1136"

这边有什么问题吗 他说偏置没找到,不应该在ckpt里面吗?

zwd13122889 commented 4 years ago

我再次查看了一下报错,如下: Key output_bias not found in checkpoint

看了一些网上的debug方法,是不是我那个BERT的模型输出 output_bias 不叫这个名字啊? 如果是这样的话,我该如何解决

zwd13122889 commented 4 years ago

我打印了一下ckpt里面的变量名,如下: image di'que 的确是没有所谓的output_bias,我想知道我改把那个的名称改成 output_bias 呢