Intel® oneAPI Data Analytics Library
Learn from community members on how to build compute-intensive applications that run efficiently on Intel® architecture.

Get trained model by neural network

Hanxi_F_
Beginner
423 Views

Hi,

Is there any method to get the trained model parameters. For example, the weight dataset of each layers? Is that possible?

I do not want to train the model repeatedly.

Thanks a lot!!!

0 Kudos
3 Replies
VictoriyaS_F_Intel
423 Views

Hello Hanxi,

There are several possibilities to get the parameters of the trained model:

  • Directly from forward layers of neural network by using your_layer.input.get(layers::forward::weights) to get the weights for the forward layer as a Tensor and your_layer.input.get(layers::forward::biases) to get the biases respectively.
  • From an instance of neural_networks::training::Model.
    • To get weights and biases for the particular layer please use getWeightsAndBiases(layerId) method. It returns weights and biases for the layer packed into single numeric table.
    • To get weights and biases for the whole network please use getWeightsAndBiases() method.

​All the getters methods mentioned above have pair setters that are used for setting the pre-trained parameters to the model of neural network.

Please have a look at our neural_net_predict_dense_batch.cpp example to see how to perform neural networks prediction with the pre-trined parameters.

Best regards,

Victoriya

0 Kudos
Hanxi_F_
Beginner
423 Views

Thanks Victoriya!

That's what I need!

BTW, I've looked up the manual and find it a little bit hard to get all the member functions I need.Is there any easy way to get them?

 

Thanks.

0 Kudos
VictoriyaS_F_Intel
423 Views

Please have a look at Developer Guide and Reference for Intel® DAALIt contains the descriptions of all the Intel® DAAL classes and their members. For example, here is the description of neural_networks::training::Model class.

Best regards,

Victoriya

0 Kudos
Reply