模型转换时如何更改批量大小?

时间:2019-04-19 02:26:30

标签: tensorflow-lite

2019-04-19 09:53:07.409720: F tensorflow/lite/toco/tooling_util.cc:1449] Check failed: batch == 1 (128 vs. 1)
Fatal Python error: Aborted

Current thread 0x00007f39d5ad9700 (most recent call first):
  File "/home/yuchen/anaconda2/envs/tryTF/lib/python3.6/site-packages/tensorflow/lite/toco/python/toco_from_protos.py", line 33 in execute
  File "/home/yuchen/anaconda2/envs/tryTF/lib/python3.6/site-packages/absl/app.py", line 251 in _run_main
  File "/home/yuchen/anaconda2/envs/tryTF/lib/python3.6/site-packages/absl/app.py", line 300 in run
  File "/home/yuchen/anaconda2/envs/tryTF/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 40 in run
  File "/home/yuchen/anaconda2/envs/tryTF/lib/python3.6/site-packages/tensorflow/lite/toco/python/toco_from_protos.py", line 59 in main
  File "/home/yuchen/anaconda2/envs/tryTF/bin/toco_from_protos", line 10 in <module>
Aborted (core dumped)

_____________错误消息高于_________________

  

我尝试将tf(.pb)模型转换为tflite(.tflite)模型。它似乎   转换器将仅接受batch_size == 1而不能接受   自动将batch_size从128(我的训练批次)更改为1。

尝试了Batch_size 1和128的两个,但它们不起作用。

import tensorflow as tf
convert= tf.lite.TFLiteConverter.from_frozen_graph("frozen.pb",input_arrays=["Placeholder_2"],output_arrays=["l2_normalize"],input_shapes={"Placeholder_2":[128, 100, 129]})
tflite_model=convert.convert()
open("model.tflite","wb").write(tflite_model)

如何将批量大小更改为1

0 个答案:

没有答案