Git Product home page Git Product logo

Comments (14)

Roshanson avatar Roshanson commented on August 9, 2024 1

这个问题应该是模型量化后存储路径的问题 args.py 里面有2个输出路径
output_dir 和 graph_file 如果自己更改了路径需要注意相对目录路径 当然你也可以不存储 让optimize_graph()直接输出量化后的计算图

from bert-utils.

terrifyzhao avatar terrifyzhao commented on August 9, 2024

please show me the code

from bert-utils.

manxin0821 avatar manxin0821 commented on August 9, 2024

from bert-utils.

terrifyzhao avatar terrifyzhao commented on August 9, 2024

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.

xhero05 avatar xhero05 commented on August 9, 2024

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\tmpnr2b3oim
INFO:tensorflow:Using config: {'_model_dir': 'C:\Users\ADMINI
1\AppData\Local\Temp\tmpnr2b3oim', '_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.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.

bound2020 avatar bound2020 commented on August 9, 2024

我也遇到了同样的问题

from bert-utils.

zhouygg avatar zhouygg commented on August 9, 2024

i have the same problem.
create file directory for output file first.

from bert-utils.

terrifyzhao avatar terrifyzhao commented on August 9, 2024

I added the code to create the output folders automatically, please pull the code again

from bert-utils.

zhouygg avatar zhouygg commented on August 9, 2024

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\ADMINI
1\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\ADMINI
1\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 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.

terrifyzhao avatar terrifyzhao commented on August 9, 2024

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.

terrifyzhao avatar terrifyzhao commented on August 9, 2024

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.

huangxiancun avatar huangxiancun commented on August 9, 2024

这个怎么解决 好痛苦

from bert-utils.

huangxiancun avatar huangxiancun commented on August 9, 2024

看到你update 了 多谢🙏

from bert-utils.

huangxiancun avatar huangxiancun commented on August 9, 2024

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 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

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.