【问题标题】:cloud ml engine version create error 3cloud ml引擎版本创建错误3
【发布时间】:2017-12-25 16:32:37
【问题描述】:

我复制并使用了这段代码。网址:http://fdahms.com/2017/03/05/tensorflow-serving-jvm-client/

但是部署版本时出错。

Model validation failed: Serving metagraph must contain exactly one SignatureDef with key: serving_default 

我试图参考https://github.com/tensorflow/serving/blob/master/tensorflow_serving/example/mnist_saved_model.py修复代码

import tensorflow as tf


x = tf.placeholder(tf.float32, shape=(None))
y = tf.placeholder(tf.float32, shape=(None))

three = tf.Variable(3, dtype= tf.float32)
z = tf.scalar_mul(three, x) + y

import os
from tensorflow.python.util import compat

model_version = 1
path = os.path.join("three_x_plus_y", str(model_version))
builder = tf.saved_model.builder.SavedModelBuilder(path)

legacy_init_op = tf.group(tf.tables_initializer(), name='legacy_init_op')

tensor_info_x = tf.saved_model.utils.build_tensor_info(x)
tensor_info_y = tf.saved_model.utils.build_tensor_info(y)
tensor_info_z = tf.saved_model.utils.build_tensor_info(z)

prediction_signature = (
      tf.saved_model.signature_def_utils.build_signature_def(
          inputs= {'egg': tensor_info_x, 'bacon': tensor_info_y},
          outputs= {'spam': tensor_info_z},
          method_name=tf.saved_model.signature_constants.PREDICT_METHOD_NAME))


with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())

    builder.add_meta_graph_and_variables(
        sess,[tf.saved_model.tag_constants.SERVING],
        signature_def_map= {
            "magic_model": prediction_signature},
        legacy_init_op=legacy_init_op
        )
    builder.save()

但我遇到了同样的错误......

我正在使用“谷歌云机器运行引擎” 我需要帮助..感谢您的阅读。

【问题讨论】:

    标签: tensorflow-serving google-cloud-ml-engine


    【解决方案1】:

    将signature_def_map 中的密钥从magic_model 更改为serving_default。

    with tf.Session() as sess:
        sess.run(tf.global_variables_initializer())
    
        builder.add_meta_graph_and_variables(
            sess,[tf.saved_model.tag_constants.SERVING],
            signature_def_map= {
                "serving_default": prediction_signature},
            legacy_init_op=legacy_init_op
            )
    

    【讨论】:

    • 谢谢!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :)!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
    猜你喜欢
    • 2019-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-15
    • 1970-01-01
    相关资源
    最近更新 更多