How can I save a trained model using python and load the same model and use it in MATLAB
40 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Suppose I trained a tensorflow deep learning model using Python. How to save that in . mat file.
Again load that trained model in MATLAB and use it.
0 commentaires
Réponses (1)
Milan Bansal
le 26 Mar 2024
Hi Anusaya,
I understand that you want to save a TensorFlow deep learning model trained using Python and then use the saved model in MATLAB.
Please refer to the steps given below to achieve this.
1.) After training your model, save it using the "save_model" function from TensorFlow's "keras.models" module. This will save your model in the SavedModel format. This will save the model in the form of a directory. Please refer to the below Python code for saving the TensorFlow model.
Python Code: model.save('tensorFlowModel')
2.) Now, load the saved TensorFlow model directly into MATLAB using the "importNetworkFromTensorFlow" function. Please refer to the following code snippet:
modelDir = "tensorFlowModel";
net = importNetworkFromTensorFlow(modelDir);
Additionally, to save this model as ".mat", use the "save" function in MATLAB. Please refer to the following code snippet:
save("matlabModel", "net");
Please refer to the following documentation link to learn more about "importNetworkFromTensorFlow".
Please refer to the following documentation link to learn more about "Save and load models" in TensorFlow.
Hope this helps.
0 commentaires
Voir également
Catégories
En savoir plus sur Pretrained Networks from External Platforms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!