报错 | Requested return tensor ‘final_encodes:0‘ not found in graph def

6 篇文章 0 订阅
2 篇文章 1 订阅
Traceback (most recent call last):
  File "/usr/local/anaconda3/envs/tf15/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/local/anaconda3/envs/tf15/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/tech/tony/ccks_triple_extract-master/albert_zh/extract_feature.py", line 92, in predict_from_queue
    for i in prediction:
  File "/usr/local/anaconda3/envs/tf15/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 619, in predict
    features, None, ModeKeys.PREDICT, self.config)
  File "/usr/local/anaconda3/envs/tf15/lib/python3.6/site-packages/tensorflow_estimator/python/estimator/estimator.py", line 1146, in _call_model_fn
    model_fn_results = self._model_fn(features=features, **kwargs)
  File "/tech/tony/ccks_triple_extract-master/albert_zh/extract_feature.py", line 75, in model_fn
    return_elements=['final_encodes:0'])
  File "/usr/local/anaconda3/envs/tf15/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
    return func(*args, **kwargs)
  File "/usr/local/anaconda3/envs/tf15/lib/python3.6/site-packages/tensorflow/python/framework/importer.py", line 431, in import_graph_def
    raise ValueError(str(e))
ValueError: Requested return tensor 'final_encodes:0' not found in graph def

在使用Albert的时候报了这么一个错,结果发现自己循环多次定义了BertVector。
看到github上bert-util2的Issue中的
https://github.com/terrifyzhao/bert-utils/issues/1
这里指出,不要在循环中使用或多次调用BertVector(),检查自己的代码,保证BertVector()只被声明一次,而bert.encode(contents)可以被多次使用,问题解决。

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值