Converting Neural Network Model file from Python to Matlab

49 visualizaciones (últimos 30 días)
Paramonte
Paramonte el 7 de Dic. de 2021
Comentada: David Willingham el 8 de Dic. de 2021
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

Respuestas (1)

David Willingham
David Willingham el 7 de Dic. de 2021
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 comentarios
Paramonte
Paramonte el 8 de Dic. de 2021
The neural network was created with the TensorFlow version 2.6.1
David Willingham
David Willingham el 8 de Dic. de 2021
I'd still recommend updating the support package:
Then we can check if the network created in TF 2.6.1 can be imported.

Iniciar sesión para comentar.

Categorías

Más información sobre Deep Learning Toolbox en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by