【发布时间】:2018-03-22 03:16:28
【问题描述】:
嗨:现在我正在将一个 tensorflow 检查点模型转换为一个 caffe 模型。我已成功读取图表并提取了每个节点中的 attr 值。我在“Conv2D”节点中获得了“dilations”、“strides”和“padding”属性的值以及“weights”节点中的形状,但我无法获得“shape”属性的值,它在 Conv2D 的输入中为空节点。但是,这些形状显示在 tensorboard 的图表中。 这是我的代码:
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
和张量板图: tensorboard_graph
请注意,Conv2D 节点的输入形状为 ?x79x79x32,它必须存储在模型文件的某个位置。有谁能帮忙吗?任何点击都会有帮助,谢谢。
【问题讨论】:
标签: python tensorflow caffe