使用snpe将tensorflow .pb转换为.dlc失败

时间:2017-10-27 01:39:33

标签: tensorflow snpe

我构建了一个演示。我将图表保存在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();

转换cmd

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

错误消息

2017-10-26 01:55:15919 - 390 - INFO - INFO_ALL_BUILDING_LAYER_W_NODES:使用节点构建图层(ElementWiseMul):[u' input_1 / mul']

〜/ snpe-sdk / snpe-1.6.0 / lib / python / converters / tensorflow / layers / eltwise.py:108:RuntimeWarning:error_code = 1002; error_message =图层参数值无效。图层input_1 / mul:至少需要两个输入,有1个; error_component =模型验证; LINE_NO = 732;的thread_id = 140514161018688   output_name中)

2017-10-26 01:55:15,920 - 390 - INFO - INFO_ALL_BUILDING_LAYER_W_NODES:使用节点构建图层(ElementWiseSum):[u'输出/输出']

〜/ snpe-sdk / snpe-1.6.0 / lib / python / converters / tensorflow / layers / eltwise.py:84:RuntimeWarning:error_code = 1002; error_message =图层参数值无效。层输出/输出:至少需要两个输入,有1个; error_component =模型验证; LINE_NO = 732;的thread_id = 140514161018688   output_name中)

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分: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

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