I want to reorganize the nodes of tensorflow .pb model,so I first get NodeDef from GraphDef, and get attr use NodeDef.attr().for the node of "Conv2D". I can get parameters such as strides,padding,data_format,use_cudnn_on_gpu from attr, but cann't get the weights format parameters. The language I use is c++. How to get it! Thank you!
If you cannot open your PB file correctly, try to right-click or long-press the file. Then click "Open with" and choose an application. You can also display a PB file directly in the browser: Just drag the file onto this browser window and drop it.
Now to save the weights only using the simple way, you just have to call the built-in function save_weights on your model. and train it for a few epochs. This will create a folder named weights_folder and save the weights in Tensorflow native format with the name of my_weights. It is going to have 3 files.
Conv2D
has two inputs: the first one is data and the second one is filter
(or weights), so you can simply check the format of the second input of Conv2D
. If you are using C++, you can try this:
# Assuming inputs: conv2d_node, node_map.
filter_node_name = conv2d_node.input(1)
filter_node = node_map[filter_node_name]
# You might need to check identity node here.
# Get the shape of filter_node using NodeDef.attr()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With