首页 > 解决方案 > 将输入馈送到估计器时,预测结果保持不变

问题描述

我试图预测 28000 张 MNIST 图片的类别,但list(predict_results)无论input_fn.

下面是预测过程的代码:

mnist_classifier =  tf.estimator.Estimator(model_fn = cnn_model_fn, model_dir = "/tmp/mnist_kaggle_model2")
for i in range(1,28000):
    input_fn = tf.estimator.inputs.numpy_input_fn(
        x = {'x': test_images[(i-1), ]},
        num_epochs = 1,
        shuffle = False
        )
    predict_results = mnist_classifier.predict(input_fn = input_fn)
    print(list(predict_results))

这是我重塑的方式test_images

test_images = test_data.reshape(28000 , 28, 28, 1)

是我重塑的方式有问题test_images,还是有问题input_fn

==================================================== ==========================

我对这个问题完全感到困惑,任何帮助将不胜感激。

谢谢你。

标签: pythontensorflowtensorflow-estimator

解决方案


推荐阅读