使用bert4keras加载预训练模型出现DataLossError

tensorflow.python.framework.errors_impl.DataLossError: Unable to open table file ./data/LOGO_3_gram_2_layer_8_heads_256_dim_weights.hdf5: 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?

解决: 将导入路径前加入一个函数即可:

checkpoint_path = "./data/LOGO_3_gram_2_layer_8_heads_256_dim_weights.hdf5"  改为:
checkpoint_path = tf.train.latest_checkpoint("./data/LOGO_3_gram_2_layer_8_heads_256_dim_weights.hdf5")

具体代码:

使用bert4keras加载预训练模型出现DataLossError_第1张图片 

 

 

 

你可能感兴趣的:(Python操作,tensorflow,python,深度学习)