为了账号安全,请及时绑定邮箱和手机立即绑定

Moblenet V2:将生产者版本较低的图导入生产者版本较高的图

Moblenet V2:将生产者版本较低的图导入生产者版本较高的图

慕妹3242003 2021-07-01 05:43:06
我开发了一个迁移学习应用程序,我正在为我的数据流重新训练 MobileNetV2。我正在使用来自 tensorflow-hub 的retrain.py重新训练模型并且没有进行任何修改。当我从终端运行脚本时,在将模型下载到我的用户配置文件中的临时目录后,我会直接收到此警告。Importing a graph with a lower producer version 26 into an existing graph with producer version 27. Shape inference will have run different parts of the graph with different producer versions.在调试过程中,我创建了一个test.py脚本来找出警告的来源:import tensorflow as tfimport tensorflow_hub as hubdef create_module_graph(module_spec):  """Creates a graph and loads Hub Module into it.  Args:    module_spec: the hub.ModuleSpec for the image module being used.  Returns:    graph: the tf.Graph that was created.    bottleneck_tensor: the bottleneck values output by the module.    resized_input_tensor: the input images, resized as expected by the module.    wants_quantization: a boolean, whether the module has been instrumented      with fake quantization ops.  """  FAKE_QUANT_OPS = ('FakeQuantWithMinMaxVars',                     'FakeQuantWithMinMaxVarsPerChannel')  height, width = hub.get_expected_image_size(module_spec)  with tf.Graph().as_default() as graph:    resized_input_tensor = tf.placeholder(tf.float32, [None, height, width, 3])    m = hub.Module(module_spec)    bottleneck_tensor = m(resized_input_tensor)    wants_quantization = any(node.op in FAKE_QUANT_OPS                             for node in graph.as_graph_def().node)  return graph, bottleneck_tensor, resized_input_tensor, wants_quantizationdef main():   module_spec = hub.load_module_spec('https://tfhub.dev/google/imagenet/mobilenet_v2_100_96/classification/2')   graph, bottleneck_tensor, resized_input_tensor, wants_quantization = create_module_graph(module_spec)if __name__ =='__main__':   main()并发现它起源create_module_graph于retrain.py. 当我使用从终端运行脚本时python test.py,我从上面收到生产者警告。但是,当我main()从 ipython 控制台运行时,我没有收到生产者版本警告。当我所做的只是从 tensorflow-hub 存储库创建图表时,我不确定为什么会发生这种情况。我查看了版本兼容性文档,没有看到与错误特别相关的任何内容。查看源代码,似乎表明我的图形在构建之前已减少到最低版本。这是需要担心的吗?它会改变您加载图表以进行预测的方式吗?
查看完整描述

1 回答

?
侃侃尔雅

TA贡献1801条经验 获得超15个赞

从我的 tensorflow-hub问题

TensorFlow Hub 模块包含tf.GraphDefs核心,这些模块具有格式版本号,以帮助将图形正确导入到较新版本的 TensorFlow。碰巧的是,在 2018 年 3 月 31 日公开发布的 TF-Hub 模块上传和当前 TensorFlow 版本之间,此格式版本从 26 增加到 27。

但是,我们目前还没有意识到形状推断中报告的变化对模块用户有任何可见的影响,因此我们目前的建议是忽略这些警告。它们将随着模块的下一次刷新而消失。


查看完整回答
反对 回复 2021-07-13
  • 1 回答
  • 0 关注
  • 254 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信