I have been adapting the most convolutional network from the following tensorflow tutorial : https://www.tensorflow.org/tutorials/layers
I use the same code except for the shape of the inputs. when I train and evaluate, I get good results. But I would like to see a prediction so that I can know what was misclassified. However when running
y=SN_classifier.predict(input_fn=my_data_to_predict)
where my_data_to_predict is a numpy array of right shape, I get the following output :
<generator object Estimator.predict at 0x7fb1ecefeaf0>
I've read on forums that I should be able to read it my doing : for i in y: print(i)
But it raises 'numpy.ndarray' object is not callable
Same happens if I try :
print('Predictions: {}'.format(list(y))
which I read on other forums..
Would you have any idea of why it doesn't output my predictions ?
Here is the part of the code where I define the predict :
predictions = {
# Generate predictions (for PREDICT and EVAL mode)
"classes": tf.argmax(input=logits, axis=1),
# Add `softmax_tensor` to the graph. It is used for PREDICT and by the
# `logging_hook`.
"probabilities": tf.nn.softmax(logits, name="softmax_tensor")
}
if mode == tf.estimator.ModeKeys.PREDICT:
return(tf.estimator.EstimatorSpec(mode=mode, predictions=predictions))
And where I call it :
y=SN_classifier.predict(input_fn=my_data_to_predict)
Thank you very much for your help, I'll take any advice, idea :)
input_fn
should be a function that generates a tensor. Wrapping it in anumpy_input_fn
should be all you need.