0

我将图形保存到 .pb 文件中。将 .pb 转换为 .dlc 时出现错误。有谁知道为什么?

我构建模型的代码:

import tensorflow as tf
from tensorflow.python.framework.graph_util import convert_variables_to_constants
from tensorflow.python.ops import variable_scope

X = tf.placeholder(tf.float32, shape=[None, 1], name="input");


with variable_scope.variable_scope("input"):
    a = tf.Variable([[1]], name="a", dtype=tf.float32);
    g = X * a


with variable_scope.variable_scope("output"):
    b = tf.Variable([[0]], name="b", dtype=tf.float32);
    ss = tf.add(g, b, name="output")


sess = tf.Session();
sess.run(tf.global_variables_initializer());


graph = convert_variables_to_constants(sess, sess.graph_def, ["output/output"])
tf.train.write_graph(graph, './linear/', 'graph.pb', as_text=False)

sess.close();

转换命令:

snpe-tensorflow-to-dlc --graph graph_sc.pb -i input 1 --out_node output/output --allow_unconsumed_nodes

错误信息:

2017-10-26 01:55:15,919 - 390 - INFO - INFO_ALL_BUILDING_LAYER_W_NODES: Building layer (ElementWiseMul) with nodes: [u'input_1/mul']

~/snpe-sdk/snpe-1.6.0/lib/python/converters/tensorflow/layers/eltwise.py:108: RuntimeWarning: error_code=1002; error_message=Layer paramter value is invalid. Layer input_1/mul: at least two inputs required, have 1; error_component=Model Validation; line_no=732; thread_id=140514161018688
  output_name)

2017-10-26 01:55:15,920 - 390 - INFO - INFO_ALL_BUILDING_LAYER_W_NODES: Building layer (ElementWiseSum) with nodes: [u'output/output']

~/snpe-sdk/snpe-1.6.0/lib/python/converters/tensorflow/layers/eltwise.py:84: RuntimeWarning: error_code=1002; error_message=Layer paramter value is invalid. Layer output/output: at least two inputs required, have 1; error_component=Model Validation; line_no=732; thread_id=140514161018688
  output_name)
4

2 回答 2

0

snpe-tensorflow-to-dlc的 input_dim 参数应该是 3 维张量,如下例所示,

snpe-tensorflow-to-dlc --graph $SNPE_ROOT/models/inception_v3/tensorflow/inception_v3_2016_08_28_frozen.pb
                       --input_dim input "1,299,299,3" --out_node "InceptionV3/Predictions/Reshape_1" --dlc inception_v3.dlc
                       --allow_unconsumed_nodes

有关使用神经处理 SDK 将 TensorFlow 模型转换为 DLC 的更详细参考,请点击以下链接, https://developer.qualcomm.com/docs/snpe/model_conv_tensorflow.html

于 2019-08-13T10:33:08.210 回答
0

SNPE 需要 3D 张量作为输入。尝试将您的命令更新-i input 1-i input 1,1,1

于 2017-12-06T08:45:18.813 回答