【问题标题】:Order of tensorflow predictions张量流预测的顺序
【发布时间】:2017-04-28 15:29:56
【问题描述】:

我正在使用 Tensorflow,训练了一个很宽的网络,并且想要预测一些值。我使用了Tensorflow iris prediction example 之类的网络,但将预测部分从

new_samples = np.array([[6.4, 3.2, 4.5, 1.5], [5.8, 3.1, 5.0, 1.7]], dtype=float)
y = list(classifier.predict(new_samples, as_iterable=True))

在我自己的输入函数中从我的测试文件中读取数据的可能性:

y = list(classifier.predict(input_fn=lambda: input_fn(test_file_name, batch_size, batch_number)))

经过一些测试我发现预测顺序不是文件的数据顺序。如何强制 TensorFlow 输出正确修正的预测?作为另一种选择,我如何打印带有特征(和线的标签)的预测?

感谢您的支持。

【问题讨论】:

    标签: python numpy machine-learning neural-network tensorflow


    【解决方案1】:

    8 个月后回答这个问题,但万一其他人偶然发现这个问题并有同样的问题——我怀疑问题是你使用了像

    这样的输入函数
    def get_input_fn(data_set, num_epochs=None, shuffle=True):
      return tf.estimator.inputs.pandas_input_fn(
        x=pd.DataFrame(data_set[FEATURES]),
        y=pd.Series(data_set[LABELS]),
        num_epochs=num_epochs,
        shuffle=shuffle, num_threads=1)
    

    这很好,但是当您运行 predict() 时,您需要设置 shuffle=False(否则它会打乱您的输出!)

    【讨论】:

      猜你喜欢
      • 2019-07-20
      • 2017-11-22
      • 2017-08-16
      • 2017-04-13
      • 1970-01-01
      • 1970-01-01
      • 2018-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多