How can I add a mechanism batchto input_fnthe TensorFlow Wide and Deep Learning Tutorial , surpassing that some functions are presented as tf.Sparsetensorobjects?
I made many attempts to add tf.train.slice_input_producer, and tf.train.batchto the source code (see. Below), but could not get away until now.
I would like the global work on this input_fn to be convenient while you train and evaluate the model.
Can someone help please?
def input_fn(df):
continuous_cols = {k: tf.constant(df[k].values)
for k in CONTINUOUS_COLUMNS}
categorical_cols = {k: tf.SparseTensor(indices=[[i, 0] for i in range(df[k].size)],
values=df[k].values,
shape=[df[k].size, 1]) for k in CATEGORICAL_COLUMNS}
feature_cols = dict(continuous_cols.items() + categorical_cols.items())
labels = tf.constant(df[LABEL_COLUMN].values)
'''
Changes from here:
'''
features_slices, features_slices = tf.train.slice_input_producer([features_cols, labels], ...)
features_batches, labels_batches = tf.train.batch([features_slices, features_slices], ...)
return features_batches, labels_batches
source
share