Sergio Bernardo Sergio Bernardo - 3 months ago 60
Python Question

Tensorflow 'features' format

I'm a total begginer with AI and tensorflow, so please forgive if this is a dumb question.
I've trained a tensorflow network using a script based on this tutorial:

https://www.tensorflow.org/versions/r0.10/tutorials/wide_and_deep/index.html

I believe training was ok.
Now I whant to run this method to make a prediction for a single input:

tf.contrib.learn.DNNClassifier.predict_proba(x=x)


But I cannot find any documentation on how to build the "x" parameter...
I tryed:

x = {k: tf.SparseTensor(indices=[[0, 0]], values=[d_data[k]], shape=[1, 1]) for k in COLUMNS}


Where:
d_data is a dictionary containing about 150 key/value pairs.
COLUMNS is a list with all the keys needed.
This same setup was used to train the network.

But got the error:

AttributeError: 'dict' object has no attribute 'dtype'


So... x should not be a 'dict'... but what should it be then?
Can anyone give me some directions?

Thanks a lot.

Answer

The BaseEstimator class has better documentation.

x: Matrix of shape [n_samples, n_features...]. Can be iterator that returns arrays of features. The training input samples for fitting the model. If set, `input_fn` must be `None`.

I will looking into getting the documentation here fixed. Thanks for pointing out.

Comments