Comments (14)
这个问题应该是模型量化后存储路径的问题 args.py 里面有2个输出路径
output_dir 和 graph_file 如果自己更改了路径需要注意相对目录路径 当然你也可以不存储 让optimize_graph()直接输出量化后的计算图
from bert-utils.
please show me the code
from bert-utils.
from bert-utils.
I haven't come across this problem,maybe the reason is that the code will generates a temporary file(it is graph file),But you don't have read and write access to the file
from bert-utils.
i have same problem
os : win10
from extract_feature import BertVector
bv = BertVector()
I:BERT_VEC:[graph:opt: 35]:model config: D:/bert/b2/bert-utils\chinese_L-12_H-768_A-12/bert_config.json
I:BERT_VEC:[graph:opt: 41]:build graph...
I:BERT_VEC:[graph:opt: 92]:load parameters from checkpoint...
I:BERT_VEC:[graph:opt: 94]:freeze...
INFO:tensorflow:Froze 181 variables.
INFO:tensorflow:Converted 181 variables to const ops.
I:BERT_VEC:[graph:opt: 97]:optimize...
E:BERT_VEC:[graph:opt:110]:fail to optimize the graph!
E:BERT_VEC:[graph:opt:111]:[Errno 2] No such file or directory: 'D:/bert/b2/bert-utils\chinese_L-12_H-768_A-12/../tmp/result/tmp930th5rk'
WARNING:tensorflow:Using temporary folder as model directory: C:\Users\ADMINI1\AppData\Local\Temp\tmpnr2b3oim1\AppData\Local\Temp\tmpnr2b3oim', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': None, '_save_checkpoints_secs': 600, '_session_config': gpu_options {
INFO:tensorflow:Using config: {'_model_dir': 'C:\Users\ADMINI
per_process_gpu_memory_fraction: 1.0
allow_growth: true
}
graph_options {
optimizer_options {
global_jit_level: ON_1
}
}
, '_keep_checkpoint_max': 5, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 100, '_train_distribute': None, '_device_fn': None, '_protocol': None, '_eval_distribute': None, '_experimental_distribute': None, '_service': None, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x000001E280056588>, '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1}
INFO:tensorflow:Could not find trained model in model_dir: C:\Users\ADMINI~1\AppData\Local\Temp\tmpnr2b3oim, running initialization to predict.
INFO:tensorflow:Calling model_fn.
Exception in thread Thread-6:
Traceback (most recent call last):
File "C:\Users\Administrator\Anaconda3\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Users\Administrator\Anaconda3\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "D:/bert/b2/bert-utils\extract_feature.py", line 83, in predict_from_queue
for i in prediction:
File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\estimator\estimator.py", line 577, in predict
features, None, model_fn_lib.ModeKeys.PREDICT, self.config)
File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\estimator\estimator.py", line 1195, in _call_model_fn
model_fn_results = self._model_fn(features=features, **kwargs)
File "D:/bert/b2/bert-utils\extract_feature.py", line 60, in model_fn
graph_def.ParseFromString(f.read())
File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 125, in read
self._preread_check()
File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 85, in _preread_check
compat.as_bytes(self.__name), 1024 * 512, status)
File "C:\Users\Administrator\Anaconda3\lib\site-packages\tensorflow\python\util\compat.py", line 61, in as_bytes
(bytes_or_text,))
TypeError: Expected binary or unicode string, got None
from bert-utils.
我也遇到了同样的问题
from bert-utils.
i have the same problem.
create file directory for output file first.
from bert-utils.
I added the code to create the output folders automatically, please pull the code again
from bert-utils.
I:BERT_VEC:[graph:opt: 42]:build graph...
I:BERT_VEC:[graph:opt: 95]:load parameters from checkpoint...
I:BERT_VEC:[graph:opt: 97]:freeze...
INFO:tensorflow:Froze 181 variables.
INFO:tensorflow:Converted 181 variables to const ops.
I:BERT_VEC:[graph:opt:100]:optimize...
I:BERT_VEC:[graph:opt:108]:write graph to a tmp file: D:\opensource\bert-utils-master\tmp\result\tmpr8i4x_4o
WARNING:tensorflow:Using temporary folder as model directory: C:\Users\ADMINI1\AppData\Local\Temp\tmpuoe5xqbz
INFO:tensorflow:Using config: {'_model_dir': 'C:\Users\ADMINI1\AppData\Local\Temp\tmpuoe5xqbz', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': None, '_save_checkpoints_secs': 600, '_session_config': gpu_options {
per_process_gpu_memory_fraction: 1
allow_growth: true
}
INFO:tensorflow:Using config: {'_model_dir': 'C:\Users\ADMINI
The folder will change while running extract feature.
next time i get the following error when i run the same script in Spyder:
Reloaded modules: modeling, tokenization, graph, args
I:BERT_VEC:[graph:opt: 36]:model config: D:\opensource\bert-utils-master\chinese_L-12_H-768_A-12/bert_config.json
I:BERT_VEC:[graph:opt: 42]:build graph...
I:BERT_VEC:[graph:opt: 95]:load parameters from checkpoint...
I:BERT_VEC:[graph:opt: 97]:freeze...
INFO:tensorflow:Froze 181 variables.
INFO:tensorflow:Converted 181 variables to const ops.
I:BERT_VEC:[graph:opt:100]:optimize...
I:BERT_VEC:[graph:opt:108]:write graph to a tmp file: D:\opensource\bert-utils-master\tmp\result\tmp_ojuei03
WARNING:tensorflow:Using temporary folder as model directory: C:\Users\ADMINI1\AppData\Local\Temp\tmp2hmoh95j1\AppData\Local\Temp\tmp2hmoh95j', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': None, '_save_checkpoints_secs': 600, '_session_config': gpu_options {
INFO:tensorflow:Using config: {'_model_dir': 'C:\Users\ADMINI
per_process_gpu_memory_fraction: 1
allow_growth: true
}
graph_options {
optimizer_options {
global_jit_level: ON_1
}
}
, '_keep_checkpoint_max': 5, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 100, '_train_distribute': None, '_device_fn': None, '_service': None, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x0000023208A94C88>, '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1}
INFO:tensorflow:Could not find trained model in model_dir: C:\Users\ADMINI~1\AppData\Local\Temp\tmp2hmoh95j, running initialization to predict.
INFO:tensorflow:Calling model_fn.
Exception in thread Thread-8:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\importer.py", line 418, in import_graph_def
graph._c_graph, serialized, options) # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.InvalidArgumentError: Requested return tensor 'final_encodes:0' not found in graph def
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\ProgramData\Anaconda3\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "D:/opensource/bert-utils-master/extract_feature.py", line 83, in predict_from_queue
for i in prediction:
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\estimator\estimator.py", line 543, in predict
features, None, model_fn_lib.ModeKeys.PREDICT, self.config)
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\estimator\estimator.py", line 1133, in _call_model_fn
model_fn_results = self._model_fn(features=features, **kwargs)
File "D:/opensource/bert-utils-master/extract_feature.py", line 66, in model_fn
return_elements=['final_encodes:0'])
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\util\deprecation.py", line 454, in new_func
return func(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\importer.py", line 422, in import_graph_def
raise ValueError(str(e))
ValueError: Requested return tensor 'final_encodes:0' not found in graph def
from bert-utils.
the path of the folder doesn't affect the output,the output has processed in graph.py,please confirm whether the version of tensorflow is greater than 1.11
from bert-utils.
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\importer.py", line 422, in import_graph_def
raise ValueError(str(e))
ValueError: Requested return tensor 'final_encodes:0' not found in graph def
only run one script at a same time
from bert-utils.
这个怎么解决 好痛苦
from bert-utils.
看到你update 了 多谢🙏
from bert-utils.
I:BERT_VEC:[graph:opt: 42]:build graph...
I:BERT_VEC:[graph:opt: 95]:load parameters from checkpoint...
I:BERT_VEC:[graph:opt: 97]:freeze...
INFO:tensorflow:Froze 181 variables.
INFO:tensorflow:Converted 181 variables to const ops.
I:BERT_VEC:[graph:opt:100]:optimize...
I:BERT_VEC:[graph:opt:108]:write graph to a tmp file: D:\opensource\bert-utils-master\tmp\result\tmpr8i4x_4o
WARNING:tensorflow:Using temporary folder as model directory: C:\Users\ADMINI1\AppData\Local\Temp\tmpuoe5xqbz INFO:tensorflow:Using config: {'_model_dir': 'C:\Users\ADMINI1\AppData\Local\Temp\tmpuoe5xqbz', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': None, '_save_checkpoints_secs': 600, '_session_config': gpu_options {
per_process_gpu_memory_fraction: 1
allow_growth: true
}
The folder will change while running extract feature.
next time i get the following error when i run the same script in Spyder:Reloaded modules: modeling, tokenization, graph, args
I:BERT_VEC:[graph:opt: 36]:model config: D:\opensource\bert-utils-master\chinese_L-12_H-768_A-12/bert_config.json
I:BERT_VEC:[graph:opt: 42]:build graph...
I:BERT_VEC:[graph:opt: 95]:load parameters from checkpoint...
I:BERT_VEC:[graph:opt: 97]:freeze...
INFO:tensorflow:Froze 181 variables.
INFO:tensorflow:Converted 181 variables to const ops.
I:BERT_VEC:[graph:opt:100]:optimize...
I:BERT_VEC:[graph:opt:108]:write graph to a tmp file: D:\opensource\bert-utils-master\tmp\result\tmp_ojuei03
WARNING:tensorflow:Using temporary folder as model directory: C:\Users\ADMINI1\AppData\Local\Temp\tmp2hmoh95j INFO:tensorflow:Using config: {'_model_dir': 'C:\Users\ADMINI1\AppData\Local\Temp\tmp2hmoh95j', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': None, '_save_checkpoints_secs': 600, '_session_config': gpu_options {
per_process_gpu_memory_fraction: 1
allow_growth: true
}
graph_options {
optimizer_options {
global_jit_level: ON_1
}
}
, '_keep_checkpoint_max': 5, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 100, '_train_distribute': None, '_device_fn': None, '_service': None, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x0000023208A94C88>, '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1}
INFO:tensorflow:Could not find trained model in model_dir: C:\Users\ADMINI~1\AppData\Local\Temp\tmp2hmoh95j, running initialization to predict.
INFO:tensorflow:Calling model_fn.
Exception in thread Thread-8:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\importer.py", line 418, in import_graph_def
graph._c_graph, serialized, options) # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.InvalidArgumentError: Requested return tensor 'final_encodes:0' not found in graph defDuring handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\ProgramData\Anaconda3\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "D:/opensource/bert-utils-master/extract_feature.py", line 83, in predict_from_queue
for i in prediction:
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\estimator\estimator.py", line 543, in predict
features, None, model_fn_lib.ModeKeys.PREDICT, self.config)
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\estimator\estimator.py", line 1133, in _call_model_fn
model_fn_results = self._model_fn(features=features, **kwargs)
File "D:/opensource/bert-utils-master/extract_feature.py", line 66, in model_fn
return_elements=['final_encodes:0'])
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\util\deprecation.py", line 454, in new_func
return func(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\importer.py", line 422, in import_graph_def
raise ValueError(str(e))
ValueError: Requested return tensor 'final_encodes:0' not found in graph def
Today, i meet this problem,then,i deal with it successfully, Whether you can check your code get BertVector() instence in one cycle or not?
from bert-utils.
Related Issues (20)
- 如果希望对特定种类的文本的句子提取句子向量,怎样对模型进行微调更合适 HOT 1
- 模型训练正常,auc较好,设置为PREDICT模式时候抛错issue 3770
- 相似度计算
- 你好,想请教下怎样加载albert-tiny,small,可以支持下这个吗?
- 请教一下,利用问答对进行fine-turning后的模型,然后获取向量的方法跟extract_feature文件中的方法一致么?此外,这样获取向量跟训练阶段是不一致的,因为输入数据是单个,训练的时候是一对数据?
- 如何用自己的语料库微调模型
- 请问一下这个怎么看结果啊
- The BQ Corpus.pdf 无法查看
- 加载过graph后,还是比较慢,所需时间是 bert-as-service的20倍,这是为什么? HOT 2
- 对sentence进行相似度预测时输入分词错误 HOT 1
- 本机windows环境中转向量正常, 在linux环境下启动脚本,程序僵死,一直处于高cpu占用状态
- 直接用bert句向量结果计算相似度,任意两个句子的余弦值都很高,请问这是什么原因 HOT 4
- 请问生成句向量的模块如何使用tfServing进行部署?
- 请问句向量的负值怎样能去掉或者变成全部正的呢?只能用relu函数变成0吗?
- 为什么运行feature.py时,没有graph生成,
- 这个是怎么回事 HOT 1
- 你这个代码有个大坑! HOT 2
- 运行extract-feature.py时遇到的问题。 HOT 2
- 缺少相关配置文件 HOT 1
- similarity识别率太低
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bert-utils.