TensorFlow Model Predict
Libraries:
Deep Learning Toolbox /
Python Neural Networks
Description
The TensorFlow Model Predict block predicts responses using a pretrained Python®
TensorFlow™ model running in the MATLAB® Python environment. MATLAB supports the reference implementation of Python,
often called CPython. If you use a Mac or Linux® platform, you already have Python installed. If you use Windows®, you need to install a distribution, such as those found at https://www.python.org/downloads/. For
more information, see Configure Your System to Use Python. Your MATLAB Python environment must have the
tensorflow
module installed. The TensorFlow Model Predict block has
been tested using Python version 3.10 and tensorflow
version 2.12.0.
Load a Python model into the block by specifying the path to a TensorFlow model that you
saved in Python in SavedModel
format or as a Keras HDF5
file. You can optionally load a Python function to preprocess the input data that Simulink® passes to the Python model, and a Python function to postprocess the predicted
responses from the model.
The input port In1 receives input data, optionally rearranges the input array dimensions, and converts the input data to a Python array. The preprocessing function (if specified) processes the converted data in Python and passes it to the TensorFlow model. The model generates predicted responses for the input data in Python and passes the responses to the Python postprocessing function (if specified). The output port Out1 returns the predicted responses.
You can add and configure input and output ports using the Inputs and Outputs tabs of the Block Parameters dialog box (see Inputs and Outputs). The software attempts to automatically populate the table in each tab when you click the Autofill Fields From Model File button on the Specify model file tab.
Note
You cannot run the TensorFlow Model Predict block in Rapid Accelerator mode.
Examples
Ports
Input
Output
Parameters
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
Version History
Introduced in R2024a
See Also
Blocks
- PyTorch Model Predict | ONNX Model Predict | Custom Python Model Predict | Scikit-learn Model Predict (Statistics and Machine Learning Toolbox)