I\'m using the code from the MNIST tutorial:
feature_columns = [tf.contrib.layers.real_valued_column(\"\", dimension=4)]
classifier = tf.contrib.learn.DNNCla
To be as close as possible to the tutorial use:
print('Predictions: {}' .format(list(ds_predict_tf)))
Sorry, the answer is very easy, you need to use the predictor
as generator
object:
g1 = ds_predict_tf
[g1.__next__() for i in range(100)]
The DNNClassifier predict function by default have as_iterable=True. Thus, it returns an generator. For getting values of predictions instead of generator, pass as_iterable=False in classifier.predict method.
For example,
classifier.predict(input_fn = _my_predict_data,as_iterable=False)
For understanding more about classifier methods and arguments. Here is a part of documentation for predict method.
From DNNClassifier documentation:
Args:
Returns:
Solution:-
pred = classifier.fit(x=training_set.data, y=training_set.target, steps=2000).predict(test_set.data)
print ("Predictions:")
print(list(pred))
That's it...
What you received and saved to ds_predict_tf
is a generator expression.
To print it you can do:
for i in ds_predict_tf:
print i
or
print(list(ds_predict_tf))
You can read more about genexpr here.