【问题标题】:Tensorflow 'features' formatTensorFlow“特征”格式
【发布时间】:2016-08-05 12:09:27
【问题描述】:

我是 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 个键/值对的字典。 COLUMNS 是一个包含所有所需键的列表。 使用相同的设置来训练网络。

但得到错误:

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

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

非常感谢。

【问题讨论】:

    标签: python artificial-intelligence tensorflow


    【解决方案1】:

    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`.
    

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

    【讨论】:

      【解决方案2】:

      我遇到了同样的错误,但我认为这是因为我们使用的是较旧版本的 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。

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-06-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-12-12
        • 1970-01-01
        • 2016-11-10
        • 2020-11-13
        相关资源
        最近更新 更多