Can I use the neural network trained by matlab to export and save python files like *. py for other programs?

Can I use the neural network trained by matlab to export and save python files like *. py for other programs?

6 Comments

If i understand correctly, you have several python source code files, .py files, and you have examples of the same source code translated into other languages, and you wish to create a neural network that can accept python source code .py files and translate them to other languages automatically ???
Maybe there is something wrong with my expression
I made an LSTM model using matlab. I hope other software can call this model to do calculations, but other software has only Python interface, so I have to call my LSTM model made by matlab through python... What should I do?
".py" is the file extension used for python source code. I would think it likely that those are UTF-8 encoded text files. It is for code, not for data storage.
Python can be used to read -v5 and -v5.3 and -v7 .mat files using
import scipy.io
mat = scipy.io.loadmat('file.mat')
This cannot handle -v7.3 files, but those are HDF5 files internally so Python HDF5 interfaces can be used.
Now, it is possible that the python code you wish to use expects the files to be in a particular format. If so we would need to know which format was expected.
For example MATLAB has exportONNXNetwork as one of the external file formats that are supported for export.
I use the LSTM model trained by matlab
save net in the *. mat file
after all, I want to use my model to make predictions
[net,YPred] = predictAndUpdateState(net,XTest,'ExecutionEnvironment','cpu')
The python side gives the data, and the matlab side gives the model and the calculation results for the python side to perform other operations
So I just need to save my net in the *. mat file for python to call?
Can python use the predictAndUpdateState function?

Sign in to comment.

 Accepted Answer

Hi,
As of R2022b you can export deep learning models to as native python code in tensorflow using the function exportnetworktotensorflow.

More Answers (0)

Categories

Tags

Community Treasure Hunt

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

Start Hunting!