[英]Tensorflow [Toco] convert Model to optimized format cause ValueError
I just started trying Tensorflow, I'd like to do some experiments on Android, but I read that Tensorflow for Poets (the version for mobile) support .tflite while the models I downloaded and found googling are .pb. 我刚开始尝试Tensorflow,我想在Android上做一些实验,但是我读到Tensorflow for Poets(移动版)支持.tflite,而我下载并发现谷歌搜索的模型是.pb。
So I decided to convert them using toco, but when I execute the command to convert I always get this error 因此,我决定使用toco进行转换,但是当我执行转换命令时,总是会遇到此错误
ValueError: Invalid tensors 'input' were found.
ValueError:找到无效的张量“输入”。
The CLI command is: CLI命令是:
toco --graph_def_file=tensorflow_inception_graph.pb --output_file=optimized_graph.tflite --input_format=TENSORFLOW_GRAPHDEF --output_format=TFLITE --input_shape=1,300,300,3 --input_array=input --o
utput_array=final_result --inference_type=FLOAT --inference_input_type=FLOAT
What's wrong with that? 怎么了
Stacktrace 堆栈跟踪
File "/home/Mitro/venv/bin/toco", line 11, in <module>
sys.exit(main())
File "/home/Mitro/venv/lib/python3.5/site-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 401, in main
app.run(main=run_main, argv=sys.argv[:1])
File "/home/Mitro/venv/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 125, in run
_sys.exit(main(argv))
File "/home/Mitro/venv/lib/python3.5/site-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 397, in run_main
_convert_model(tflite_flags)
File "/home/Mitro/venv/lib/python3.5/site-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 100, in _convert_model
converter = _get_toco_converter(flags)
File "/home/Mitro/venv/lib/python3.5/site-packages/tensorflow/contrib/lite/python/tflite_convert.py", line 87, in _get_toco_converter
return converter_fn(**converter_kwargs)
File "/home/Mitro/venv/lib/python3.5/site-packages/tensorflow/contrib/lite/python/lite.py", line 271, in from_frozen_graph
sess.graph, input_arrays)
File "/home/Mitro/venv/lib/python3.5/site-packages/tensorflow/contrib/lite/python/convert_saved_model.py", line 189, in get_tensors_from_tensor_names
",".join(invalid_tensors)))
Run this script changing the model_file parameter to the pb file, and as an output you will have something like this: 运行此脚本,将model_file参数更改为pb文件,作为输出,您将具有以下内容:
Tensor("import/ Placeholder :0", shape=(?, 299, 299, 3), dtype=float32) Tensor(“ import / 占位符 :0”,shape =(?, 299,299,3),dtype = float32)
Tensor("import/ final_result :0", shape=(?, 5), dtype=float32) 张量(“ import / final_result :0”,shape =(?, 5),dtype = float32)
in this case they are the parameters that you must pass through 在这种情况下,它们是您必须通过的参数
--input_array = Placeholder --input_array = 占位符
--output_array = final_result --output_array = final_result
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.