Python 预测不会以张量流结束

Python 预测不会以张量流结束,python,tensorflow,google-cloud-platform,prediction,Python,Tensorflow,Google Cloud Platform,Prediction,我使用Tensorflow框架编写了一个神经网络,但当我尝试进行一些预测时,程序并没有结束 这个程序包含很多文件,我将尝试在这里发布主要的文件,但简而言之,我有一个自定义的模型函数和一个实验者来训练和评估它 我必须使用实验者API,因为程序需要在本地和云中运行,但在第一种情况下,我不想使用Tensorflow服务来运行我的预测 注意:该项目类似于您可以在 我的模型函数 实验者 预测 以前发布的所有内容都很完美,现在是时候做出一些预测了。正如我所说的,我不想使用Tensorflow局部服务,所以我

我使用Tensorflow框架编写了一个神经网络,但当我尝试进行一些预测时,程序并没有结束

这个程序包含很多文件,我将尝试在这里发布主要的文件,但简而言之,我有一个自定义的模型函数和一个实验者来训练和评估它

我必须使用实验者API,因为程序需要在本地和云中运行,但在第一种情况下,我不想使用Tensorflow服务来运行我的预测

注意:该项目类似于您可以在

我的模型函数 实验者 预测 以前发布的所有内容都很完美,现在是时候做出一些预测了。正如我所说的,我不想使用Tensorflow局部服务,所以我尝试使用相同的模型和相同的配置创建一个估计器

    classifier = tf.estimator.Estimator(
    generate_model_fn(
        learning_rate=args.learning_rate,
        hidden_units=args.hidden_units,
        dropout=args.dropout,
        weights=args.weights,
    ),
    config=run_config.RunConfig(model_dir=args.job_dir),
)
根据日志文件,模型似乎恢复正确,因此我想尝试仅使用一条记录进行简单预测。这个程序永远不会结束,它一直在运行,直到我的机器完全倾斜

 def predict_input_fn():
    x = {
        'FN': tf.constant(['A']),
        'SS': tf.constant([1]),
        'SN': tf.constant([2]),
        'SL': tf.constant([3]),
        'NS': tf.constant([4]),
        'NN': tf.constant([5]),
        'NL': tf.constant([6]),
        'LS': tf.constant([7]),
        'LN': tf.constant([8]),
        'LL': tf.constant([9]),
        'FT': tf.constant([0])
    }
    y = x['FT']
    return x,y


predictions = classifier.predict(input_fn=predict_input_fn)
    classifier = tf.estimator.Estimator(
    generate_model_fn(
        learning_rate=args.learning_rate,
        hidden_units=args.hidden_units,
        dropout=args.dropout,
        weights=args.weights,
    ),
    config=run_config.RunConfig(model_dir=args.job_dir),
)
 def predict_input_fn():
    x = {
        'FN': tf.constant(['A']),
        'SS': tf.constant([1]),
        'SN': tf.constant([2]),
        'SL': tf.constant([3]),
        'NS': tf.constant([4]),
        'NN': tf.constant([5]),
        'NL': tf.constant([6]),
        'LS': tf.constant([7]),
        'LN': tf.constant([8]),
        'LL': tf.constant([9]),
        'FT': tf.constant([0])
    }
    y = x['FT']
    return x,y


predictions = classifier.predict(input_fn=predict_input_fn)