1

我开发了一个迁移学习应用程序,我正在为我的数据流重新训练 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 tf
import tensorflow_hub as hub

def 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_quantization


def 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_graphretrain.py. 当我使用从终端运行脚本时python test.py,我从上面收到生产者警告。但是,当我main()从 ipython 控制台运行时,我没有收到生产者版本警告。

当我所做的只是从 tensorflow-hub 存储库创建图表时,我不确定为什么会发生这种情况。我查看了版本兼容性文档,并没有看到任何与该错误特别相关的内容。翻看源代码,似乎表明我的图表在构建它之前已经缩减到最低版本。

  1. 这有什么好担心的吗?
  2. 它是否会改变您加载图表以进行预测的方式?
4

1 回答 1

1

从我的 tensorflow-hub问题

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

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

于 2018-11-02T15:16:32.517 回答