Deep Learning Toolbox Converter for TensorFlow Models
Import and export TensorFlow models within MATLAB
8,8K Descargas
Actualizado
11 dic 2024
The converter for TensorFlow models enables you to import a pretrained TensorFlow model and weights and export a MATLAB network or layergraph as a TensorFlow model.
Import:
Note: the model must be saved in TensorFlow in the SavedModel format before importing to MATLAB.
For TensorFlow 2 models up to version 2.15, save the model (myModelTF, expressed as a tf.Keras.Model object) with the following command in TensorFlow first:
model.save("myModelTF")
For TensorFlow 2 models with versions 2.16 or later, TensorFlow will be installed with Keras 3 instead of Keras 2. To ensure compatibility with importNetworkFromTensorFlow, please build and save the save the model using the Keras 2 API using the following Python commands.
First, install the Keras 2 (tf_keras) package in bash:
pip install tf_keras
Then, precede any import tensorflow statement by the following lines of code:
import os
os.environ["TF_USE_LEGACY_KERAS"] = "1"
import tensorflow
Next, instead of importing the keras (Keras 3) package directly, import tf_keras (Keras 2) as keras:
import tf_keras as keras
from tf_keras import layers
Finally, save the model:
model.save("myModelTF")
The TensorFlow Model Importer has been tested up to 2.15. SavedModels saved with versions 2.15 and higher may also work without issues. When using tf_keras for versions 2.15 and higher, Keras 3 specific features such as Keras Ops will not be supported.
Export:
Export supports:
- TensorFlow v2.0 or later, no support for Keras 3.0
- Python version 3.0 or later
Compatibilidad con la versión de MATLAB
Se creó con
R2017b
Compatible con cualquier versión desde R2017b hasta R2025a
Compatibilidad con las plataformas
Windows macOS (Apple Silicon) macOS (Intel) LinuxCategorías
Más información sobre Deep Learning Toolbox en Help Center y MATLAB Answers.
Etiquetas
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Descubra Live Editor
Cree scripts con código, salida y texto formateado en un documento ejecutable.