如何从TensorFlow .pb模型中获取权重格式?



我想重新组织tensorflow .pb模型的节点,所以我首先从GraphDef获取NodeDef,并使用NodeDef.attr((.为"Conv2D"的节点获取attr。 我可以从 attr 获取步长、填充、data_format、use_cudnn_on_gpu 等参数,但无法获取权重格式参数。 我使用的语言是 c++。 如何获得它!谢谢!

Conv2D有两个输入:第一个是数据,第二个是filter(或权重(,因此您只需检查Conv2D的第二个输入的格式即可。如果您使用的是C++,则可以尝试以下操作:

# Assuming inputs: conv2d_node, node_map.
filter_node_name = conv2d_node.input(1)
filter_node = node_map[filter_node_name]
# You might need to check identity node here.
# Get the shape of filter_node using NodeDef.attr()

最新更新