【问题标题】:how to find tfslim output node names如何找到 tfslim 输出节点名称
【发布时间】:2018-09-05 19:04:52
【问题描述】:

在用 tensorflow 和 slim 训练了一些模型之后,我试图冻结模型和权重。但是我很难找到输出节点名称,这是freeze_graph.freeze_graph()所必需的。

我的输出层如下所示:

 conv4_1 = slim.conv2d(net,num_outputs=2,kernel_size=[1,1],stride=1,scope='conv4_1',activation_fn=tf.nn.softmax)
    #conv4_1 = slim.conv2d(net,num_outputs=1,kernel_size=[1,1],stride=1,scope='conv4_1',activation_fn=tf.nn.sigmoid)

    print conv4_1.get_shape()
    #batch*H*W*4
    bbox_pred = slim.conv2d(net,num_outputs=4,kernel_size=[1,1],stride=1,scope='conv4_2',activation_fn=None)

conv4_1 是 softmaxed 类,无论是否面对。 bbox_pred 是边界框回归。

当我使用tf.train.write_graph(self.sess.graph_def, output_path, 'model.pb') 保存图表并将model.pb 作为文本打开时,我发现图表如下所示:

node {
name: "conv4_1/weights/Initializer/random_uniform/shape"
...
node {
name: "conv4_1/kernel/Regularizer/l2_regularizer"
...
node {
name: "conv4_1/Conv2D"
op: "Conv2D"
input: "conv3/add"
input: "conv4_1/weights/read"
...
node {
name: "conv4_1/Softmax"
op: "Softmax"
input: "conv4_1/Reshape"
...
node {
  name: "Squeeze"
  op: "Squeeze"
  input: "conv4_1/Reshape_1"
  attr {
    key: "T"
    value {
      type: DT_FLOAT
    }
  }
  attr {
    key: "squeeze_dims"
    value {
      list {
        i: 0
      }
    }
  }
}

那么,问题来了,输出节点名称是什么?

只有 tensorflow 编写层的方法可以设置“名称”,例如:

             .conv(3, 3, 32, 1, 1, padding='VALID', relu=False, name='conv3')
         .prelu(name='PReLU3')
         .conv(1, 1, 2, 1, 1, relu=False, name='conv4-1')
         .softmax(3,name='prob1'))

    (self.feed('PReLU3') #pylint: disable=no-value-for-parameter
         .conv(1, 1, 4, 1, 1, relu=False, name='conv4-2'))

但我在 tensorflow slim 中找不到设置输出名称的方法。

谢谢!

【问题讨论】:

  • 你解决过这个问题吗?

标签: tensorflow tensorflow-slim


【解决方案1】:

三个初始模型的输出节点名称如下:

inception v3:InceptionV3/Predictions/Reshape_1
inception v4:InceptionV4/Logits/Predictions
inception resnet v2 : InceptionResnetV2/Logits/Predictions

【讨论】:

  • 您是如何找到上述 3 个模型的输出节点名称的?我正在寻找 TF Slim Resnet_v1_50 和 Resnet_v2_50 的输入和输出节点名称,但找不到。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-06-19
  • 2023-04-08
  • 2022-09-23
  • 2021-12-06
  • 2019-01-23
  • 2017-02-23
  • 2013-11-27
相关资源
最近更新 更多