Intel® oneAPI Data Analytics Library
Community support for building compute-intensive applications that run fast on Intel® architecture.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

Get trained model by neural network

Hanxi_F_
Beginner
146 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
146 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

Hanxi_F_
Beginner
146 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.

VictoriyaS_F_Intel
146 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

Reply