tensorflow - TensorFlow saved_model 为不同的输入返回相同的结果
问题描述
我正在尝试使用下面的代码导出保存的模型。它导出了 saved_model.pb,但是对于我给它的任何输入,我都会得到相同的结果。我认为我的输出方式有问题。我对 TensorFlow 很陌生,所以如果这是一个简单的错误,我深表歉意。
with tf.gfile.FastGFile("retrained_graph.pb", 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
_ = tf.import_graph_def(graph_def, name='')
def export_model(saved_model_dir, final_tensor_name):
with tf.Session() as sess:
init = tf.global_variables_initializer()
sess.run(init)
with sess.graph.as_default() as graph:
tf.saved_model.simple_save(
sess,
saved_model_dir,
inputs={'image': tf.placeholder(tf.string)},
outputs={'prediction': graph.get_tensor_by_name(final_tensor_name + ":0")}
)
我还在使用以下教程中的 retrain.py:https://github.com/BartyzalRadek/Multi-label-Inception-net所以它可能是那里的东西。
我的代码结构是我将其包含在一个单独的文件中,因此每次我想保存时都不需要重新训练。
解决方案
推荐阅读
- aws-api-gateway - 如果在 Terraform 模块中创建了 aws_api_gateway_integration,如何在 aws_api_gateway_deployment 资源上填充depends_on?
- ios - 无法在 ViewController 之间移动
- java - 循环中的加密和解密在 Java 中的第一次迭代后给出更快的结果
- html - @media print page size=A4 正在生成一个稍大的页面,并且边框正在渗入上一页
- node.js - Nodejs中多个客户端到单个服务器之间的连接
- sql-server - 不支持 KBMMW ORM MetaExists(mwmdtTable)
- laravel - "" 目录不存在 - php artisan into do droplet 由 forge 创建
- hibernate - 将 Hibernate SELECT 语句记录到它们自己的日志文件中
- reactjs - React 内部的工作循环持续多长时间?
- java - 将 2 小数转换为整数