My project is visualization of CNN 2d model and I have to get a NN-layer object from checkpoint model file. Does Tensorflow allow user to get layer object?
In fact, I just want the stride or padding value from Conv2d or Relu.
It's hard to get a Layer object from the checkpoint only.
But you can get the convolutional attributes programmatically by calling:
tf.get_default_graph().as_graph_def()
... assuming that you've restored the checkpoint into a default graph. It returns the list of graph nodes (GraphDef proto to be exact), among which there are also Conv2D nodes, like this one:
node {
name: "conv2d/Conv2D"
op: "Conv2D"
input: "input_layer"
input: "conv2d/kernel/read"
attr {
key: "T"
value {
type: DT_FLOAT
}
}
attr {
key: "data_format"
value {
s: "NHWC"
}
}
attr {
key: "padding"
value {
s: "SAME"
}
}
attr {
key: "strides"
value {
list {
i: 1
i: 1
i: 1
i: 1
}
}
}
attr {
key: "use_cudnn_on_gpu"
value {
b: true
}
}
}
You just need to find the node that corresponds to the particular layer you're interested in.