我开发了一个迁移学习应用程序,我正在为我的数据流重新训练 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 存储库创建图表时,我不确定为什么会发生这种情况。我查看了版本兼容性文档,没有看到与错误特别相关的任何内容。查看源代码,似乎表明我的图形在构建之前已减少到最低版本。这是需要担心的吗?它会改变您加载图表以进行预测的方式吗?
添加回答
举报
0/150
提交
取消