Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TensorFlow estimator.predict() gives WARNING:tensorflow:Input graph does not contain a QueueRunner

I'm trying to get a prediction with a custom input function with estimator.predict, but it gives me this:

WARNING:tensorflow:Input graph does not contain a QueueRunner. That means predict yields forever. This is probably a mistake.

It doesn't give me an error, but predict just says that its restoring parameters and doesn't return the actual predictions. Here is my code:

test_data = [0.03, 0.91, 0.95, 0.10, 0.56, 0.93]
test_data_in = { k: test_data[index] for index, k in enumerate(FEATURES) }
print(test_data_in)

def predict_input_fn(data_set):
    feature_cols = { k: tf.reshape(tf.constant(data_set[k], dtype=tf.float32), [-1]) for k in FEATURES }
    return feature_cols

predictions = estimator.predict(input_fn=lambda: predict_input_fn(test_data_in))
print(list(predictions))

I've looked at this issue, but I couldn't find a solution related to my problem. Why does TensorFlow show this warning and how do I get rid of it?

like image 616
Sheikh Avatar asked Oct 20 '17 21:10

Sheikh


2 Answers

I hit this too, reading the thread https://github.com/tensorflow/tensorflow/issues/11621

I think your program is perfectly correct and it's the warning that's wrong :). It was added long before the Datasets API existed, and was well intentioned. (AFAICT the predict() API relies on your input terminating with a tf.errors.OutOfRangeError and before Datasets existed only QueueRunner-based pipelines would terminate that way, so it probably was an error if no queue runners existed.) @xiejw Should we remove this warning, or is there a more cunning way to detect the error condition?

Hopefully they will remove the error when it's unnecessary.

like image 164
LYu Avatar answered Oct 27 '22 00:10

LYu


Until they change the behaviour of this warning, here's a quick patch to suppress it:

tf.estimator.Estimator._validate_features_in_predict_input = lambda *args: None

Include this line after importing tensorflow.

It shouldn't have any unintended side effects, but have a look at the source code if you want to convince yourself.

like image 31
黄雨伞 Avatar answered Oct 27 '22 00:10

黄雨伞