keras ResNet50模型的eval_input_receiver_fn()的困难

时间:2019-06-24 07:42:28

标签: python tensorflow keras tensorflow-estimator tfx

我试图通过以下方式使自定义eval_input_receiver_fn()传递给tfma.export.export_eval_savedmodel()

model = tf.keras.models.load_model('/Users/user/Documents/../model_name.h5')
resnet50 = tf.feature_column.numeric_column('resnet50_input:0')
def receiver_fn():
    serialized_tf_example = tf.compat.v1.placeholder(
        dtype=tf.string, shape=[None], name='input_example_tensor')

    receiver_tensors = {'examples': serialized_tf_example}

    feature_spec = tf.feature_column.make_parse_example_spec(
        [resnet50])
    features = tf.io.parse_example(serialized_tf_example, feature_spec)
    return tfma.export.EvalInputReceiver(
        features=features,
        receiver_tensors=receiver_tensors)

tfma.export.export_eval_savedmodel(
    estimator=estimator,
    export_dir_base=eval_model_dir,
    eval_input_receiver_fn=receiver_fn)

但是,我收到以下错误:

  

TypeError:函数EvalInputReceiver必须使用标签来调用   指定

在我的情况下如何指定标签?

0 个答案:

没有答案