bojone / SPACES

端到端的长本文摘要模型(法研杯2020司法摘要赛道)
386 stars 91 forks source link

加载NEZHA-base时找不到position embedding #10

Closed TianshangLiu closed 3 years ago

TianshangLiu commented 3 years ago
Traceback (most recent call last):
  File "final.py", line 12, in <module>
    import extract_vectorize as vectorize
  File "/mnt/data/liuts/competition/cail-2020/SPACES/extract_vectorize.py", line 35, in <module>
    nezha_checkpoint_path,
  File "/mnt/data/liuts/competition/cail-2020/venv/lib/python3.6/site-packages/bert4keras/models.py", line 2297, in build_transformer_model
    transformer.load_weights_from_checkpoint(checkpoint_path)
  File "/mnt/data/liuts/competition/cail-2020/venv/lib/python3.6/site-packages/bert4keras/models.py", line 255, in load_weights_from_checkpoint
    values = [self.load_variable(checkpoint, v) for v in variables]
  File "/mnt/data/liuts/competition/cail-2020/venv/lib/python3.6/site-packages/bert4keras/models.py", line 255, in <listcomp>
    values = [self.load_variable(checkpoint, v) for v in variables]
  File "/mnt/data/liuts/competition/cail-2020/venv/lib/python3.6/site-packages/bert4keras/models.py", line 649, in load_variable
    variable = super(BERT, self).load_variable(checkpoint, name)
  File "/mnt/data/liuts/competition/cail-2020/venv/lib/python3.6/site-packages/bert4keras/models.py", line 232, in load_variable
    return tf.train.load_variable(checkpoint, name)
  File "/mnt/data/liuts/competition/cail-2020/venv/lib/python3.6/site-packages/tensorflow/python/training/checkpoint_utils.py", line 84, in load_variable
    return reader.get_tensor(name)
  File "/mnt/data/liuts/competition/cail-2020/venv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 678, in get_tensor
    return CheckpointReader_GetTensor(self, compat.as_bytes(tensor_str))
tensorflow.python.framework.errors_impl.NotFoundError: Key bert/embeddings/position_embeddings not found in checkpoint

预训练模型是从https://github.com/huawei-noah/Pretrained-Language-Model/tree/master/NEZHA-TensorFlow给的链接下载的, 百度网盘和google 网盘都尝试了,还是存在这个问题...

bojone commented 3 years ago

很明显,报错出在extract_vectorize.py的第35行,该行带有nezha_checkpoint_path字眼,而我写的extract_vectorize.py里边根本没有nezha_checkpoint_path字眼,所以你的这个代码并不是我写的,因此你应该需要找写该代码的人提问,而不是找我。

TianshangLiu commented 3 years ago

很明显,报错出在extract_vectorize.py的第35行,该行带有nezha_checkpoint_path字眼,而我写的extract_vectorize.py里边根本没有nezha_checkpoint_path字眼,所以你的这个代码并不是我写的,因此你应该需要找写该代码的人提问,而不是找我。

谢谢苏神 bug解决了