python - 在不使用 tf.session() 的情况下获取 Tensorflow model.predict 的值
问题描述
所以我有一个用 tensorflow 的新估计器 API 编写的预测网络
我这样称呼预测:
prediction = classifier_mycolumn.predict(cust_train_fn)
其中classifier_mycolumn
定义为:
classifier_mycolumn = tf.estimator.Estimator(
model_fn = model_function,
params = {'feature_columns': my_feature_columns,
'n_classes': 1,},
model_dir=current_model)
只是一个标准的 tf.estimator.Estimator 东西。
cust_train_fn
实际上不是一个函数,它是网络应该接收并运行推理的单个数组。
网络应该返回 0 或 1(最后使用 softmax 的简单分类) - 但每次我尝试打印时prediction
- 我只是得到<generator object Estimator.predict at 0x7fe0e8630c50>
有什么办法可以得到预测的实际结果?例如,网络返回的 0 或 1?!非常感谢您的阅读。
解决方案
推荐阅读
- android - PeriodicWorkRequest not working periodically
- python - Django forms stop form processing on ValidationError
- php - phpMyAdmin Database Not found
- python - 关于重新加载模块的说明
- nginx - Nginx : 允许 Googlebot 并检查其他访问者是否经过身份验证
- button - 如何使用多个按钮?
- visual-studio-code - 我在导入引导程序 5 期间遇到问题
- javascript - 每次再次调用函数时如何更新创建的每个字母?
- webpack - 创建自定义模块的文档或指南
- php - 如何使用表单将图像上传到 mysql 数据库上的 blob 类型