Tensorflow 'features' 格式

Tensorflow 'features' format

我是 AI 和 tensorflow 的初学者,如果这是一个愚蠢的问题,请原谅。 我已经使用基于本教程的脚本训练了一个 tensorflow 网络:

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

我觉得训练还行。 现在我想 运行 这个方法来对单个输入进行预测:

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

但是我找不到任何关于如何构建 "x" 参数的文档... 我试过了:

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

在哪里: d_data 是一个包含大约 150 个 key/value 对的字典。 COLUMNS 是一个包含所有所需键的列表。 同样的设置用于训练网络。

但出现错误:

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

所以... x 不应该是 'dict'... 但它应该是什么? 谁能给我一些指示?

非常感谢。

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

我会考虑修复此处的文档。谢谢指出。

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

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

在我当前的版本中,此函数没有 'input_fn',因此必须输入张量矩阵对象作为 x。

您在此期间找到解决方案了吗?