Converting Neural Network Model file from Python to Matlab
조회 수: 54 (최근 30일)
이전 댓글 표시
Dear all
We have developed a CNN model in Python and would like to convert the model to Matlab.
We have exported the Python model to a h5 format file.
However we hare having trouble about having Matlab to import this file.
So far we have used importkerasnetwork matlab function and get the following error:
Warning: File 'new_model_doceis.h5' was saved in Keras version '2.7.0'. Import of Keras versions newer than '2.2.4' is
not supported. The imported model may not exactly match the model saved in the Keras file.
Error using nnet.internal.cnn.keras.LayerTranslator/importWeights (line 223)
Assertion failed.
Error in nnet.internal.cnn.keras.LayerSpec.fromBaseLayer (line 32)
this.Weights = importWeights(this.Translator, this.Name, SubmodelName, WeightFile, H5Info);
Error in nnet.internal.cnn.keras.KerasLayerInsideModel/expandLayer (line 26)
LSpec = nnet.internal.cnn.keras.LayerSpec.fromBaseLayer(this, ImportWeights, SubmodelName,
HDF5Filename, H5Info);
Error in nnet.internal.cnn.keras.KerasModelConfig>@(L)expandLayer(L,ImportWeights,SubmodelName,HDF5Filename,H5Info)
(line 18)
[ExpandedLayerSpecs, ExpandedNameTables] = cellfun(@(L)expandLayer(L, ImportWeights, SubmodelName,
HDF5Filename, H5Info), ...
Error in nnet.internal.cnn.keras.KerasModelConfig/flattenLayer (line 18)
[ExpandedLayerSpecs, ExpandedNameTables] = cellfun(@(L)expandLayer(L, ImportWeights, SubmodelName,
HDF5Filename, H5Info), ...
Error in nnet.internal.cnn.keras.KerasSequentialModel/flatten (line 21)
[LayerSpecs, NameTable] = flattenLayer(this.Config, ImportWeights, '', HDF5Filename, H5Info);
Error in nnet.internal.cnn.keras.AssembledModel (line 38)
[this.LayerSpecs, this.InputLayerIndices, this.OutputTensors] = flatten(KM.Model, ImportWeights,
WeightFile, H5Info);
Error in nnet.internal.cnn.keras.importKerasNetwork (line 25)
AM = nnet.internal.cnn.keras.AssembledModel(KM, WeightFile);
Error in importKerasNetwork (line 91)Network = nnet.internal.cnn.keras.importKerasNetwork(modelfile, varargin{:});
Is there a way to solve this problem?
Thanks in advance
Para
댓글 수: 0
답변 (1개)
David Willingham
2021년 12월 7일
Hi,
The importer that had the most up to date functionality as it’s based on networks created in TensorFlow 2.0:
https://www.mathworks.com/help/deeplearning/ref/importtensorflownetwork.html
Was your networked created in Tensorflow 2.0?
David
댓글 수: 4
David Willingham
2021년 12월 8일
I'd still recommend updating the support package:
Then we can check if the network created in TF 2.6.1 can be imported.
참고 항목
카테고리
Help Center 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!