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!!!
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.
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?