2016-08-05 47 views
3

我是一个AI和tensorflow的总和,所以请原谅,如果这是一个愚蠢的问题。 我已经使用基于本教程的脚本培养了tensorflow网络:Tensorflow'功能'格式

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

我认为培训是确定的。 现在我whant运行这个方法做一个预测单个输入:

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

但我不能找到如何打造的“X”参数的任何文件... 我tryed:

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

其中: d_data是包含大约150个键/值对的字典。 COLUMNS是一个列表,包含所有需要的密钥。 同样的设置用于训练网络。

但得到的错误:

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

所以... X不应该是一个“字典” ...但它应该是呢? 任何人都可以给我一些方向吗?

非常感谢。

回答

2

BaseEstimator类有更好的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`. 

我会考虑在这里修复文档。感谢您指出。

0

我得到了同样的错误,但我认为这是因为我们正在使用tensorflow的旧版本(我在0.8.0),现在fit方法可以采用不同的输入类型'input_fn',我认为它可以采用字典的形式,看到here

def fit(self, x=None, y=None, input_fn=None, steps=None, batch_size=None, 
     monitors=None, max_steps=None): 

在我目前的版本此功能不会有“input_fn”,因此为什么它是强制性的输入张量矩阵对象为x。

您是否设法在此期间找到解决方案?