训练结束后没有找到.h5文件,predict前需要怎么处理?
yzq170320 opened this issue · 6 comments
train.py里checkpoint定义了模型路径在../user_data/model_data/
如果这里也找不到,看看训练时的报错
训练的时候没有成功加载预训练,使用tf.train.latest_checkpoint(path)的方式,值为None。并且没有启用对抗训练。但训练时没有报错
确保tf版本为1.14,bert4keras为0.4.3
已经将tf版本修正为1,14,bert4keras为0.4.3。但是还是会出现加载模型的问题。模型是从官网下载的,只含有权重
Traceback (most recent call last):
File "train.py", line 206, in
model = build_model(mode='bert',filename='bert',lastfour=False)
File "train.py", line 46, in build_model
return_keras_model=False,
File "/usr/local/lib/python3.7/site-packages/bert4keras-0.4.3-py3.7.egg/bert4keras/bert.py", line 568, in build_bert_model
File "/usr/local/lib/python3.7/site-packages/bert4keras-0.4.3-py3.7.egg/bert4keras/bert.py", line 369, in load_weights_from_checkpoint
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/training/checkpoint_utils.py", line 97, in list_variables
reader = load_checkpoint(ckpt_dir_or_file)
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/training/checkpoint_utils.py", line 66, in load_checkpoint
return pywrap_tensorflow.NewCheckpointReader(filename)
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 636, in NewCheckpointReader
return CheckpointReader(compat.as_bytes(filepattern))
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 648, in init
this = _pywrap_tensorflow_internal.new_CheckpointReader(filename)
tensorflow.python.framework.errors_impl.DataLossError: Unable to open table file ../data/External/bert/bert_model.ckpt: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
那可能是模型权重的问题?模型权重从这里下载:
https://github.com/bojone/bert4keras
已解决模型权重的问题,谢谢