我开发了一个迁移学习应用程序,正在为我的数据流重新培训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_graph
中的retrain.py
函数。当我使用python test.py
从终端运行脚本时,从上方收到生产者警告。但是,当我从ipython控制台运行main()
时,没有得到生产者版本警告。
我不确定为什么我正在做的所有事情都是从tensorflow-hub repo创建图形时发生的。我查看了version compatibility docs,但没有发现与该错误特别相关的任何内容。浏览源代码code,似乎表明我的图形在构造之前已降至最低版本。
答案 0 :(得分:1)
从我的tensorflow-hub issue:
TensorFlow Hub模块的核心包含tf.GraphDefs
,并且它们具有格式版本号,以帮助将图形正确导入到TensorFlow的较新版本中。碰巧的是,在2018年3月31日公开发布的TF-Hub模块上传到当前的TensorFlow版本之间,此格式版本从26升至27。
但是,我们目前尚不了解所报告的形状推断变化对模块用户的任何可见影响,因此我们当前的建议是忽略这些警告。他们将与 下次刷新模块。