首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将tensorflow .pb转换为.dlc失败,出现snpe

将tensorflow .pb转换为.dlc失败,出现snpe
EN

Stack Overflow用户
提问于 2017-10-27 09:39:33
回答 2查看 1.9K关注 0票数 0

我将图形保存为.pb文件。当我将.pb转换为.dlc时,我得到一个错误。有人知道为什么吗?

我构建模型的代码:

代码语言:javascript
复制
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();

转换命令:

代码语言:javascript
复制
snpe-tensorflow-to-dlc --graph graph_sc.pb -i input 1 --out_node output/output --allow_unconsumed_nodes

错误消息:

代码语言:javascript
复制
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)
EN

回答 2

Stack Overflow用户

发布于 2017-12-06 16:45:19

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

票数 0
EN

Stack Overflow用户

发布于 2019-08-13 18:33:08

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

代码语言:javascript
复制
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

有关使用神经处理软件开发工具包将TensorFlow模型转换为DLC的更多详细参考,请访问以下链接:https://developer.qualcomm.com/docs/snpe/model_conv_tensorflow.html

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

https://stackoverflow.com/questions/46966238

复制
相关文章

相似问题

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