Reputation: 20222
I was looking at this tutorial for creating a Convolutional Neural Network with Tensorflow.
After the neural network is built and trained, in the tutorial, it is tested like this:
eval_results = mnist_classifier.evaluate(
x=eval_data, y=eval_labels, metrics=metrics)
print(eval_results)
However, I don't have a labels for the test set, so I want to run it just with the training examples, like this:
eval_results = mnist_classifier.evaluate(x=test_data, metrics=metrics)
If I do that however, I get this warning and then the execution stops:
WARNING:tensorflow:From ../src/script.py:169: calling BaseEstimator.evaluate (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and will be removed after 2016-12-01.
Instructions for updating:
Estimator is decoupled from Scikit Learn interface by moving into
separate class SKCompat. Arguments x, y and batch_size are only
available in the SKCompat class, Estimator will only accept input_fn.
Example conversion:
est = Estimator(...) -> est = SKCompat(Estimator(...))
Traceback (most recent call last):
File "../src/script.py", line 172, in <module>
main()
File "../src/script.py", line 169, in main
eval_results = mnist_classifier.evaluate(x=test_data, metrics=metrics)
File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 289, in new_func
return func(*args, **kwargs)
File "/opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 530, in evaluate
102.5s
7
return SKCompat(self).score(x, y, batch_size, steps, metrics)
File "/opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 1365, in score
name='score')
File "/opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 816, in _evaluate_model
% self._model_dir)
tensorflow.contrib.learn.python.learn.estimators._sklearn.NotFittedError: Couldn't find trained model at /tmp/mnist_convnet_model.
Upvotes: 1
Views: 182
Reputation: 11922
You can not use mnist_classifier.evaluate
without a y
paramater, because you have nothing to evaluate.
Instead, use y = mnist_classifier.predict(x=x)
to get results, and have a look at them yourself to know if they are correct or not.
However, it's a very bad idea to do this with data that the network already trained on, because it could lead to good results that do not reflect how the network is handling new information.
Other than that, the warning you get is pretty normal, because the x
and y
arguments are deprecated anyway, but you can still use them. If you want to make the warning itself go away you should add tf.logging.set_verbosity(tf.logging.ERROR)
after you import tf
EDIT: Also, when I think about it, how come you have the labels for the training set and not for the test set? You should always split the training data and labels so that most of it is trained on, but some of it is kept exactly so you can use it in evaluate
Upvotes: 1