I currently have a CNN-LSTM model that I would like to call from MATLAB. It was developed in Keras 2.2.2. I have attempted a number of approaches that have all failed so far.
I tried to use the model as a function that is called from Matlab however, MATLAB crashes whenever the tensorflow/keras library is included in the script.
I tried to port the model over using the Tensorflow-Keras (importKerasLayers and importKerasNetwork) however the Conv1d layer is not available and custom layers can't seem to work given the 'channel last' format. In addition, it seems CNN-LSTM layers are not compatible.
I've went about working on a middle-man solution for new users to Tensorflow that typically utilize Matlab. It's a simple GUI interface that auto-codes the user inputs in the Matlab GUI into a python script that can be run utilizing the Tensorflow Python Interface.
@Louis Yu, congrats on your effort,Tensorflow for Matlab. It looks like it has high potential but there's something not quite right. I mentioned several bugs I found, which make it look like the code could never have worked. Perhaps an earlier, incomplete version got uploaded? Mind taking a look?
TensorFlow is a free Python library developed by Google Brain. As of April 2017, it has APIs in other languages (C++, Java and Go), but they are experimental.
MATLAB is a proprietary programming language developed by Mathworks (non-free). It has interfaces to other languages, including Python. Mathworks offers its own Neural Network Toolbox™. There are also plenty of other deep learning MATLAB toolboxes, many listed athttp://deeplearning.net/software_links/.
However, running TensorFlow with MATLAB is not supported by TensorFlow or Mathworks. As we can see, the MathWorks File Exchange does not havehttp://au.mathworks.com/matlabcentral/fileexchange/?utf8=%E2%9C%93&term=tensorflow. Neither does GitHub https://github.com/search?utf8=%E2%9C%93&q=matlab+tensorflow&type=. Until there is a bridge between the two, I would suggest that we are best advised to learn TensorFlow in the supported language (Python). Alternatively, if you already have paid for the MATLAB licenses (Neural Network Toolbox $1,500 Individual) (or belong to an organisation that has), you may consider learning MATLAB and the Neural Network Toolbox. This field is moving quickly, so be prepared to keep paying for the new version of Neural Network Toolbox (updates are not included in the price).
The MATLAB Neural network toolbos for an individual is about $50, not more than $1000. Look at the license options on the MathWorks website for individual license for noncommercial use.
The Rosetta Stone of deep learning is ONNX (Open Neural Network Exchange), which allows model's to be transferred (I think) between environments such as PyTorch, MXNet, Core ML, Caffe2, TensorFlow, Microsoft Cognitive Toolkit, and MATLAB - I think. Check it out for yourself by searching for the command
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
3 Comments
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/314283-how-can-i-use-tensorflow-library-from-matlab-environment#comment_468244
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/314283-how-can-i-use-tensorflow-library-from-matlab-environment#comment_468244
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/314283-how-can-i-use-tensorflow-library-from-matlab-environment#comment_987023
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/314283-how-can-i-use-tensorflow-library-from-matlab-environment#comment_987023
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/314283-how-can-i-use-tensorflow-library-from-matlab-environment#comment_1019647
Direct link to this comment
https://la.mathworks.com/matlabcentral/answers/314283-how-can-i-use-tensorflow-library-from-matlab-environment#comment_1019647
Sign in to comment.