首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TensorFlow精简版:使用toco转换为.tflite时出错

TensorFlow精简版:使用toco转换为.tflite时出错
EN

Stack Overflow用户
提问于 2018-01-05 18:58:20
回答 1查看 1.7K关注 0票数 2

我正在尝试将我的TensorFlow冻结模型转换为tflite模型。当我运行toco时,我得到如下错误消息

代码语言:javascript
复制
F tensorflow/contrib/lite/toco/graph_transformations/propagate_fixed_sizes.cc:982] Check failed: input_dims.size() == 4 (2 vs. 4)

下面是我调用toco的方式:

代码语言:javascript
复制
bazel-bin/tensorflow/contrib/lite/toco/toco \
--input_format=TENSORFLOW_GRAPHDEF \
--input_file=/tmp/output_graph.pb \
--output_format=TFLITE \
--output_file=/tmp/my_model.lite \
--inference_type=FLOAT \
--inference_input_type=FLOAT \
--input_arrays=input_layer \
--output_arrays=classes_tensor\
--input_shapes=1,227,227,3

下面是我在操作过程中的终端打印输出:

代码语言:javascript
复制
INFO: Analysed 0 targets (4 packages loaded).
INFO: Found 0 targets...
INFO: Elapsed time: 5.267s, Critical Path: 0.03s
INFO: Build completed successfully, 1 total action
2018-01-05 10:24:23.011483: W tensorflow/contrib/lite/toco/toco_cmdline_flags.cc:178] --input_type is deprecated. It was an ambiguous flag that set both --input_data_types and --inference_input_type. If you are trying to complement the input file with information about the type of input arrays, use --input_data_type. If you are trying to control the quantization/dequantization of real-numbers input arrays in the output file, use --inference_input_type.
2018-01-05 10:24:25.853112: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1122] Converting unsupported operation: IsVariableInitialized
2018-01-05 10:24:25.853197: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1122] Converting unsupported operation: RefSwitch
2018-01-05 10:24:25.853241: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1122] Converting unsupported operation: RandomShuffleQueueV2
2018-01-05 10:24:25.853268: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1122] Converting unsupported operation: QueueDequeueUpToV2
2018-01-05 10:24:26.207160: I tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.cc:39] Before general graph transformations: 64 operators, 90 arrays (0 quantized)
2018-01-05 10:24:27.327055: I tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.cc:39] After general graph transformations pass 1: 15 operators, 33 arrays (0 quantized)
2018-01-05 10:24:27.327262: I tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.cc:39] After general graph transformations pass 2: 15 operators, 34 arrays (0 quantized)
2018-01-05 10:24:27.327356: F tensorflow/contrib/lite/toco/graph_transformations/propagate_fixed_sizes.cc:982] Check failed: input_dims.size() == 4 (2 vs. 4)
/home/olu/Dev/scratch_train_sign/freeze_graph_tf.sh: line 28:  8881 Aborted 

我查看了propagate_fixed_sizes.cc文件,在982行附近找到了下面的注释

代码语言:javascript
复制
// The current ArgMax implementation only supports 4-dimensional inputs with
// the last dimension as the axis to perform ArgMax for.

在我的训练代码中,我使用ArgMax的唯一位置如下:

代码语言:javascript
复制
 predictions = { "classes": tf.argmax(input=logits, axis=1, name="classes_tensor"), "probabilities": tf.nn.softmax(logits, name="softmax_tensor") }

你知道这个问题的解决方案是什么吗?对此的解决方案将受到很好的赞赏。

EN

回答 1

Stack Overflow用户

发布于 2018-01-10 18:17:08

在GitHub上的TensorFlow bug跟踪器上提出这个问题后,答案归结为TLite目前还不完全支持ArgMax。Link

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48112174

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档