首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >导出tensorflow模型时“无法从形状推断num”

导出tensorflow模型时“无法从形状推断num”
EN

Stack Overflow用户
提问于 2017-09-29 00:32:32
回答 1查看 704关注 0票数 1

我正在尝试导出一个tensorflow模型,比如

代码语言:javascript
运行
复制
  feature_spec = { 'words': tf.FixedLenSequenceFeature([], tf.int64, allow_missing=True) }

  def serving_input_receiver_fn():
      """Build the serving inputs."""
      serialized_tf_example = tf.placeholder(dtype=tf.string,
                                             shape=[1],
                                             name='input_example_tensor')
      features = tf.parse_example(serialized_tf_example, feature_spec)
      receiver_tensors = {'words': serialized_tf_example}
      return tf.estimator.export.ServingInputReceiver(features, receiver_tensors)

  export_dir = classifier.export_savedmodel(export_dir_base=args.job_dir,
                                            serving_input_receiver_fn=serving_input_receiver_fn)

但是我收到了这个错误

代码语言:javascript
运行
复制
Cannot infer num from shape (1, ?, 128, 128)

我不知道这个?是从哪里来的,我猜它来自tf.parse_example。你知道我哪里做错了吗?

EN

回答 1

Stack Overflow用户

发布于 2017-09-29 01:17:40

在不知道完整原因的情况下,这段代码似乎工作得很好

代码语言:javascript
运行
复制
  def serving_input_receiver_fn():
    feature_spec = { "words": tf.FixedLenFeature(dtype=tf.int64, shape=[4]) }
    return tf.estimator.export.build_parsing_serving_input_receiver_fn(feature_spec)()
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46474151

复制
相关文章

相似问题

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