def get_placeholder_input_fn(config, model_type, vocab_sizes, use_crosses):
"""Wrap the get input features function to provide the metadata."""
def get_input_features():
"""Read the input features from the given placeholder."""
columns = feature_columns(config, model_type, vocab_sizes, use_crosses)
feature_spec = tf.contrib.layers.create_feature_spec_for_parsing(columns)
# Add a dense feature for the keys, use '' if not on the tf.Example proto.
feature_spec[KEY_FEATURE_COLUMN] = tf.FixedLenFeature(
[1], dtype=tf.string, default_value='')
# Add a placeholder for the serialized tf.Example proto input.
examples = tf.placeholder(tf.string, shape=(None,))
features = tf.parse_example(examples, feature_spec)
# Pass the input tensor so it can be used for export.
features[EXAMPLES_PLACEHOLDER_KEY] = examples
return features, None
# Return a function to input the feaures into the model from a placeholder.
return get_input_features
评论列表
文章目录