- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to draw Class Activation Map for my optimized model's output.
featuremap * weights = CAM
When i was using OpenVINO 2020.03ver , i can get the layer's weights like below
iec = IECore() net = iec.read_Network(model = Openvino_XML, weights = Openvino_BIN)
weight_layer = net.layers[weight_layer_name]
layer_weights = weight_layer.blobs["weights"]
But net.layers function is deprecated after 2021.2 ver
and also, layer. blobs is deprecated..
any other good solutions to get weights from specific layer? (with openvino 2022.3 ver)
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ryan34,
Thank you for reaching out to us.
We suggest you use get_ops() or get_ordered_ops() methods from nGraph Python API as the 'ie_api.IENetwork.layers' has been deprecated.
Refer to the nGraph Python API Reference for more information.
Regards,
Hairul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hairul,
Thanks for your kind reply.
I've tried nGraph as shown below,
but, get_ordered_ops() function just "return ops used in the function intopological order"
and also the get_ops() funcition
How can i get the layer's weight like this code?
layer weights = weight_layer.blobs["weights"]
weight_layer = net.layers[weight_layer_name]
layer_weights = weight_layer.blobs["weights"]
Regards,
Ryan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ryan,
We are investigating this issue further and will update you at the earliest.
Regards,
Hairul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ryan,
Thank you for your patience.
For your information, the weights are located in the Constant operations available in the network. You can use get_data() after get_ops() function to get the weight values on specific Constant operation layers.
Here is an example code for calling the get_data() method and retrieving the data tensor associated with a Constant node in OpenVINO™ 2022.2:
from openvino.inference_engine import IECore
import ngraph as ng
ie = IECore()
path_xml="vehicle-detection-adas-0002.xml"
path_bin="vehicle-detection-adas-0002.bin"
net = ie.read_network(model=path_xml, weights=path_bin)
func = ng.function_from_cnn(net)
ops = func.get_ops()
print(ops[14]) #Print the node attributes
print(ops[14].get_data()) #Specific Constant operations layer, all weights are located in the Constant operations
Regards,
Hairul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ryan,
This thread will no longer be monitored since we have provided a solution. If you need any additional information from Intel, please submit a new question.
Regards,
Hairul

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page