- The function fully supports TensorFlow-Keras versions up to 2.2.4.
- The function offers limited support for TensorFlow-Keras versions 2.2.5 to 2.4.0.
Loading saved model from keras importer
조회 수: 13 (최근 30일)
이전 댓글 표시
I tried to importing my model from a different computer using Matlab R022b. And then I got this error:
Error using nnet.internal.cnn.tensorflow.tf2mex
Invalid MEX-file
'C:\ProgramData\MATLAB\SupportPackages\R2022b\toolbox\nnet\supportpackages\keras_importer\+nnet\+internal\+cnn\+tensorflow\tf2mex.mexw64':
The file cannot be accessed by the system.
I used the same Matlab version with the same Deep learning toolbox
댓글 수: 0
답변 (2개)
Nihal Reddy
2023년 4월 10일
편집: Nihal Reddy
2023년 4월 10일
I understand you are getting an error while trying to import model using Keras importer in MATLAB R2022b.
The error message is mostly likely due the model missing a file called 'keras_metadata.pb', it is caused by inappropiate way when saving the model in TensorFlow.
This is because the model is not a Saved Model (https://www.tensorflow.org/guide/saved_model). Please regenerate model and save model using
model.save
instead of
tf.saved_model.save
Thus, the 'keras_metadata.pb' will be included, and MATLAB should import the model successfully.
Currently, "importKerasNetwork"supports TensorFlow-Keras versions as follows:
Refer to the following documentation link for more information and examples-
댓글 수: 0
Sid
2025년 10월 2일
편집: Sid
2025년 10월 2일
Hi, just need to revive this thread, since I am facing this exact problem while trying out the example:
Brain MRI Segmentation Using Pretrained 3-D U-Net Network
Early in the example, it instructs me to use :
net = importNetworkFromTensorFlow(fullfile(dataDir,"trainedSynthSegModel")).
Initially, I installed the module since it was not available, but after imstallation,
subsequent runs gave me the following error message, pasted below. running dependency walker on the tf2mex.mexw64 shows many missing dlls, almost all of them are libmex* or similar:
-------------------------
LIBMATLABDATAARRAY.DLL
LIBMEX.DLL
LIBMWFL.DLL
LIBMWFOUNDATION_FILESYSTEM.DLL
LIBMWI18N.DLL
LIBMWSPROOTUTILS.DLL
LIBMX.DLL
LIBUT.DLL
---------------------------------------
How should I proceed from this point onwards? I tried changing/adding the PATH variables in system settings, but I am still getting this error. executing !path from matlab command window whows me the path where ther libs are.
Hope to get some constructive help on this!Thanks!
Sid.
Error using nnet.internal.cnn.tensorflow.tf2mex
Invalid MEX-file 'C:\ProgramData\MATLAB\SupportPackages\R2025a\toolbox\nnet\supportpackages\keras_importer\+nnet\+internal\+cnn\+tensorflow\tf2mex.mexw64': The specified module could not be found.
Error in
smstruct = jsondecode(nnet.internal.cnn.tensorflow.tf2mex('saved_model', fullfile(obj.SavedModelPath, 'saved_model.pb')));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in
sm = savedmodel.TFSavedModel(this.ModelPath, this, true);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in
net = importManager.translate;
^^^^^^^^^^^^^^^^^^^^^^^
Error in
Network = nnet.internal.cnn.tensorflow.importTensorFlowNetwork(modelFolder, 'TargetNetwork', 'dlnetwork', 'PackageName', options.PackageName, 'Namespace',options.Namespace, 'OnlySupportDlnetwork', true, 'PreferredNestingType', options.PreferredNestingType);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in
Network = nnet.internal.cnn.tensorflow.importNetworkFromTensorFlow(modelFolder, varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!