0

From In Tensorflow for serving a model, what does the serving input function supposed to do exactly this article, I found out that 'serving input function' is for telling the model what data it has to get from the user for prediction when the model is exported. 'train input function' will refer to train input which train data would be given.

But I can't understand why these two functions are separated. I think most of the time, train data shapes and prediction data shapes would be the same. Is there any way to receive prediction data through 'train input function' instead of 'serving input function'?

I'm asking this question because I have some preprocess done in my 'train input function' but I can't to any data processing in the 'serving input function' since there is no input data given. I had no problem when there was no preprocess but what I need to do here is to make my csv input data into [batch size x window size x number of features].

This is some parts of my train input and input function:

def generate_input_fn(file_names, mode, skip_header_lines=5, batch_size = None, windows_size = None):

    column_names=((tf.contrib.timeseries.TrainEvalFeatures.TIMES,)
                + (tf.contrib.timeseries.TrainEvalFeatures.VALUES,) * 32)

    reader = tf.contrib.timeseries.CSVReader(filenames=file_names, 
                                column_names=column_names, 
                                skip_header_lines=skip_header_lines)

    input_fn = tf.contrib.timeseries.RandomWindowInputFn(
        reader, 
        batch_size=batch_size, 
        window_size=windows_size,
    )
    return input_fn



train_input = generate_input_fn(
    hparams.train_files,
    mode = tf.estimator.ModeKeys.TRAIN,
    batch_size=hparams.train_batch_size
)

I'm new with Tensorflow so if I'm getting something wrong, please adjust it.

PS. Any suggestions on how to deal with multivariate time series data??

OGCheeze
  • 74
  • 1
  • 11

1 Answers1

0

I found out myself that there are some cases that we might want to use different process for training data and prediction data. You might want to use only the feature values for the training data while you want to use other values more than the features.

For example, when you are training with 3 feature values(heights, weights, gender) and you want to put a person's name for the prediction which makes the data have 4 features(name, heights, weights, gender).

Or you might want to have different shapes of data such as you use csv for training data and json for prediction data. That was why the (training)input function and serving input functions are seperated.

OGCheeze
  • 74
  • 1
  • 11