How to import a pre trained linear regression model from python to matlab?

81 views (last 30 days)
If I trained a model using python. Is there any way to import or use that model in matlab? Finally I want to genarate a c code after adding something to that in matlab.
chaitanya kalipatnapu
chaitanya kalipatnapu on 5 May 2020
I have a doubt here.
if we are converting matlab code from .m to .c, If we have any function which is calling a python method from a .py file then, Is our tool box going to convert the packages that are being called by the python function in .py file?
please let me know if the question is not clear.
I will try to reconstruct or try to send a picture on my question.

Sign in to comment.

Answers (1)

David Fink
David Fink on 5 May 2020
To import from Python to MATLAB, save the model in a format MATLAB can import:
or a simpler format, like text or csv.
To generate C code from the imported model, use MATLAB Coder or GPU Coder:
shayne sudhakar
shayne sudhakar on 14 May 2021
Edited: shayne sudhakar on 14 May 2021
Hi David,
Thanks for your advise.
I tried this, but I was able to directly get a .h5 file of model weights from keras.
So importkeraslayers(model file) worked well.
But unfortunately the gensim(net) function does not operate on the 'net' file generated from the importkeraslayers function. It shows an error of incorrect argument datatype or missing argument in call to function 'gensim'
Can you provide me with some insight on this. Thanks a ton.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!