提供input_fn进行实验(Tensorflow)

时间:2017-09-20 18:07:00

标签: python tensorflow

我已经创建了我的serving_input_fn,以便在实验中输入导出策略,但它不起作用。

def serving_input_fn():
    receiver_tensors = {'example': tf.placeholder(tf.float32, [batch_size, None, n_inputs], name = 'inputs')}
    features = receiver_tensors['example']
    return tf.estimator.export.ServingInputReceiver(features, receiver_tensors)

def serving_input_fn():
    features = {'example': tf.placeholder(tf.float32, [batch_size, None, n_inputs], name = 'inputs')}
    receiver_tensors = features ['example']
    return tf.estimator.export.ServingInputReceiver(features, receiver_tensors)

def serving_input_fn():
    features = {'example': tf.placeholder(tf.float32, [batch_size, None, n_inputs], name = 'inputs')}
    #also tried
    #features = {'example': tf.placeholder(tf.float32, [None, n_inputs], name = 'inputs')}
    return tf.estimator.export.build_raw_serving_input_receiver_fn(features, default_batch_size = batch_size)

def experiment_fn(run_config, hparams):
    estimator = tf.estimator.Estimator(...)
        )

    export_strategies = saved_model_export_utils.make_export_strategy(serving_input_fn = serving_input_fn)

    return learn.Experiment(
        estimator = estimator,
        train_input_fn = train_input_fn,
        eval_input_fn = eval_input_fn,
        train_steps = 100,
        export_strategies = export_strategies)

这三个serving_input_fn实现都没有工作。你有什么想法吗?

谢谢!

0 个答案:

没有答案