Reputation: 806
I'm using Tensorflow, trained a wide'n'deep net and want to predict some values. I used a net like Tensorflow iris prediction example, but changed the prediction part from
new_samples = np.array([[6.4, 3.2, 4.5, 1.5], [5.8, 3.1, 5.0, 1.7]], dtype=float)
y = list(classifier.predict(new_samples, as_iterable=True))
to the possibility to read data from my test-file in my own input-function:
y = list(classifier.predict(input_fn=lambda: input_fn(test_file_name, batch_size, batch_number)))
After some tests I found that the prediction order is not the data order of the file. How can I force Tensorflow to output the predictions in the right correction? As an other option how can I print out the predictions with the features (and the label of the line)?
Thanks for your support.
Upvotes: 2
Views: 948
Reputation: 31
Answering this 8 months later, but in case anyone else stumbles upon this and has the same question- I suspect the problem was that you used an input function like
def get_input_fn(data_set, num_epochs=None, shuffle=True):
return tf.estimator.inputs.pandas_input_fn(
x=pd.DataFrame(data_set[FEATURES]),
y=pd.Series(data_set[LABELS]),
num_epochs=num_epochs,
shuffle=shuffle, num_threads=1)
Which is fine, but when you run predict() you need to set shuffle=False (otherwise it will shuffle your outputs!)
Upvotes: 2