Lan*_*ash 3 python caffe tensorflow
嗨:现在我正在将tensorflow检查点模型转换为caffe模型。我已成功读取图形并提取了每个节点中的attr值。我在“ Conv2D”节点中获得了“膨胀”,“跨步”和“填充”属性的值,在“权重”节点中获得了形状,但我无法获得“形状”属性的值,在Conv2D的输入中为空节点。但是,这些形状在张量板的图中显示。这是我的代码:
new_saver = tf.train.import_meta_graph(meta_path)
new_saver.restore(sess, tf.train.latest_checkpoint(ckpt_path))
graph_def = sess.graph_def
node_list = graph_def.node
# conv_node, weight_node, from_node are all in node_list
# conv_node: the conv2d node in graph_def
# weight_node: the weights node of conv2d
# from_node: the input feature map node of conv2d
weight_shape_attr = weight_node.attr['shape']
weight_shapes = [dim.size for dim in weight_shape_attr.shape.dim]
strides = [ii for ii in conv_node.attr['strides'].list.i]
dilations = [ii for ii in conv_node.attr['dilations'].list.i]
shapes = from_node.attr['shape'] # this is empty
Run Code Online (Sandbox Code Playgroud)
和tensorboard图: tensorboard_graph
请注意,Conv2D节点的输入的形状为?x79x79x32,它必须已存储在模型文件中的某个位置。有人可以帮忙吗?任何点击都会有所帮助,谢谢。
Tensorflow图的as_graph_def方法具有可选参数add_shapes(False默认情况下)。如果设置为,True则会导致节点的附加属性:_output_shapes。
因此,您可以尝试通过以下方式获取GraphDef:
graph_def = sess.graph.as_graph_def(add_shapes=True)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2303 次 |
| 最近记录: |