Converting Neural Network Model file from Python to Matlab
51 次查看(过去 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!