【问题标题】:"Cannot infer num from shape" when exporting tensorflow model导出张量流模型时“无法从形状推断 num”
【发布时间】:2017-09-28 16:32:31
【问题描述】:

我正在尝试导出类似的张量流模型

  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)

但我收到此错误

Cannot infer num from shape (1, ?, 128, 128)

我不知道? 来自哪里,我猜它来自tf.parse_example。关于我在这里做错了什么有什么想法吗?

【问题讨论】:

    标签: python machine-learning tensorflow google-cloud-ml-engine


    【解决方案1】:

    不知道这段代码运行良好的全部原因

      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)()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-13
      • 2016-12-12
      • 2019-02-02
      • 1970-01-01
      • 2016-08-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多