导出TF估算器

时间:2019-02-22 10:59:36

标签: python tensorflow tensorflow-estimator

我正在尝试导出tensorflow中的估算器,但遇到问题,无法正确执行。 估算器本身是根据TensorFlowHub MobilenetV2创建的 (https://tfhub.dev/google/imagenet/mobilenet_v2_035_224/feature_vector/2)+添加了一层致密层

estimator = tf.estimator.Estimator(model_fn, params=params, config=config)
estimator.train(lambda: batched_train_input_fn(args.data_dir, params))
features = {'in': tf.placeholder(tf.float32, [1, 224, 224, 3], name="in")}
ex_input_fn = estimator.export.build_raw_serving_input_receiver_fn(features, 1)
exported_model_path = estimator.export_savedmodel(os.path.join(args.model_dir, 'exported'), ex_input_fn)

模型本身的功能:

def build_model(is_training, images, params):
    import tensorflow_hub as hub
    module = hub.Module("https://tfhub.dev/google/imagenet/mobilenet_v2_035_224/feature_vector/2")

    tf_model = module(images)
    with tf.variable_scope('fc_1'):
        tf_model = tf.layers.dense(tf_model, params.embedding_size)
    return model

我收到错误消息:

  

AttributeError:“ Estimator”对象没有属性“ export”

尽管我认为export_savedmodeltf中的正常功能。

我在哪里有问题?

0 个答案:

没有答案
相关问题