Reputation: 1255
After training some model with tensorflow and slim, I am trying to freeze the model and weights. But it's quite hard for me to find out the output nodes name, which is necessary for freeze_graph.freeze_graph()
.
my output layers looks like:
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 is the softmaxed class like, face or not. bbox_pred is the bounding box regression.
when I save the graph with, tf.train.write_graph(self.sess.graph_def, output_path, 'model.pb')
and open the model.pb as text, I found that the graph looks like:
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
}
}
}
}
so, here comes the problem, which is the output node names?
tensorflow only ways of writing layers could set "names" like:
.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'))
But I can't find setting output names method in tensorflow slim.
Thanks!
Upvotes: 1
Views: 1116
Reputation: 352
Output Node names for the 3 of the inception models are given below:
inception v3 : InceptionV3/Predictions/Reshape_1
inception v4 : InceptionV4/Logits/Predictions
inception resnet v2 : InceptionResnetV2/Logits/Predictions
Upvotes: 1