Converting Neural Network Model file from Python to Matlab

39 ビュー (過去 30 日間)
Paramonte
Paramonte 2021 年 12 月 7 日
コメント済み: David Willingham 2021 年 12 月 8 日
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

回答 (1 件)

David Willingham
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 件のコメント
Paramonte
Paramonte 2021 年 12 月 8 日
The neural network was created with the TensorFlow version 2.6.1
David Willingham
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 ExchangeDeep Learning Toolbox についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by