Get parameters/weights for each layer of the model using the c++ API on OpenVINO

César Gouveia

I have been looking for a way to get the tensor of weights/parameters and biases for each layer of the network using the C++ API on the OpenVINO framework. I can't find anything on the documentation nor any example on the samples. How could I extract these tensors?

Thanks, César.

EDIT: Code for getting weights and biases separately:

for (auto&& layer : this->pImplementation->network) {
        weightsbuf << "Layer name: " << layer->name << std::endl;
        weightsbuf << "Parameters:" << std::endl;

        for (auto&& param : layer->params) {

            weightsbuf << '\t' << param.first << ": " << param.second << std::endl;
        }

        std::vector<int> kernelvect;
        auto kernelsize = layer->params.at("kernel");

        std::stringstream ss(kernelsize);

        // split by comma kernel size
        for (int i; ss >> i;) {
            kernelvect.push_back(i);
            if (ss.peek() == ',')
                ss.ignore();
        }
        int noutputs = std::stoi(layer->params.at("output"));
        int nweights = kernelvect[0] * kernelvect[1] * noutputs;
        int nbias = noutputs;

        for (auto&& blob : layer->blobs) {
            weightsbuf << '\t' << blob.first << ": ";
            for (size_t w = 0; w < nweights; ++w) {
                weightsbuf << blob.second->buffer().as<float*>()[w] << " ";
            }
            weightsbuf << std::endl;
            weightsbuf << '\t' << "biases:";
            for (size_t b = 0; b < nbias; ++b) {
                weightsbuf << blob.second->buffer().as<float*>()[nweights + b] << " ";
            }
        }
        weightsbuf << std::endl;
    }
Artemy Skrebkov

Looks like there is no official example to show that functionality. I haven't found anything like that as well.

I implemented a basic sample which prints information about each layer of a network. Please take a look: https://github.com/ArtemSkrebkov/dldt/blob/askrebko/iterate-through-network/inference-engine/samples/cnn_network_parser/main.cpp

I believe the idea how to use API is clear.

The sample is based on the current state of the dldt repo (branch '2019', it corresponds to the release 2019 R3.1)

Another link, which might be useful, is the documentation on CNNLayer class: https://docs.openvinotoolkit.org/latest/classInferenceEngine_1_1CNNLayer.html

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to get the states for each step and for each layer in a multilayer RNN using dynamic_rnn

分類Dev

C programing, For Loop to get each number without using Array

分類Dev

sorting through a Fusion layer using a loop and updating each result

分類Dev

Can openVINO model optimiser be used to convert tensorflow ann models?

分類Dev

obj-c pattern to separate model and network-layer

分類Dev

how to get a CSV from an API and map it into a model

分類Dev

Get each line from a richtextbox and export to excel cells using c#

分類Dev

How can I get layer type caffe in c++

分類Dev

Topic label of each document in LDA model using textmineR

分類Dev

See the score of each fold when cross validating a model using a for loop

分類Dev

Build API using FastAPI for Classification Model produced using pycaret

分類Dev

OpenVINOのc ++ APIを使用して、モデルの各レイヤーのパラメーター/重みを取得します

分類Dev

how to get a field from a model in django api view

分類Dev

Running Keras DNN model (UNet) using OpenCV readNetFromTensorFlow: Error: Unknown layer type Shape in op decoder_stage0_upsampling/Shape

分類Dev

How do I copy specific layer weights from pretrained models using Tensorflow Keras api?

分類Dev

Cannot forward() a net using Openvino Intermediate Representation Files, but can use ONNX file I am making an IR of

分類Dev

jQuery nested each loop not working as expected using Trello API

分類Dev

How to replace (or insert) intermediate layer in Keras model?

分類Dev

How to correctly use an intermediate layer of a vgg model

分類Dev

Visualize output of each layer in theano Convolutional MLP

分類Dev

Linked Photoshop layer masks that are inverse of each other

分類Dev

How to get data using foreign key in eloquent model?

分類Dev

How to get the attribute value which is defined in model using gson

分類Dev

NetLogo - using BehaviorSpace get all turtles locations as the result of each repetition

分類Dev

calculate total value and get percentage value of each using that total value

分類Dev

How to filter and get each object key's value using startsWith?

分類Dev

Get Top 5 Products in Each Category and Subcategory using Entity Framework

分類Dev

Add a third layer to API documentation

分類Dev

Get facebook friends posts using graph API

Related 関連記事

  1. 1

    How to get the states for each step and for each layer in a multilayer RNN using dynamic_rnn

  2. 2

    C programing, For Loop to get each number without using Array

  3. 3

    sorting through a Fusion layer using a loop and updating each result

  4. 4

    Can openVINO model optimiser be used to convert tensorflow ann models?

  5. 5

    obj-c pattern to separate model and network-layer

  6. 6

    how to get a CSV from an API and map it into a model

  7. 7

    Get each line from a richtextbox and export to excel cells using c#

  8. 8

    How can I get layer type caffe in c++

  9. 9

    Topic label of each document in LDA model using textmineR

  10. 10

    See the score of each fold when cross validating a model using a for loop

  11. 11

    Build API using FastAPI for Classification Model produced using pycaret

  12. 12

    OpenVINOのc ++ APIを使用して、モデルの各レイヤーのパラメーター/重みを取得します

  13. 13

    how to get a field from a model in django api view

  14. 14

    Running Keras DNN model (UNet) using OpenCV readNetFromTensorFlow: Error: Unknown layer type Shape in op decoder_stage0_upsampling/Shape

  15. 15

    How do I copy specific layer weights from pretrained models using Tensorflow Keras api?

  16. 16

    Cannot forward() a net using Openvino Intermediate Representation Files, but can use ONNX file I am making an IR of

  17. 17

    jQuery nested each loop not working as expected using Trello API

  18. 18

    How to replace (or insert) intermediate layer in Keras model?

  19. 19

    How to correctly use an intermediate layer of a vgg model

  20. 20

    Visualize output of each layer in theano Convolutional MLP

  21. 21

    Linked Photoshop layer masks that are inverse of each other

  22. 22

    How to get data using foreign key in eloquent model?

  23. 23

    How to get the attribute value which is defined in model using gson

  24. 24

    NetLogo - using BehaviorSpace get all turtles locations as the result of each repetition

  25. 25

    calculate total value and get percentage value of each using that total value

  26. 26

    How to filter and get each object key's value using startsWith?

  27. 27

    Get Top 5 Products in Each Category and Subcategory using Entity Framework

  28. 28

    Add a third layer to API documentation

  29. 29

    Get facebook friends posts using graph API

ホットタグ

アーカイブ