import a Keras pre-trained network into Matlab

1 回表示 (過去 30 日間)
YA
YA 2020 年 5 月 18 日
回答済み: Sivylla Paraskevopoulou 2022 年 5 月 9 日
I'm having issues to import a pre-trained network I've trained in Python into Matlab.
- I used the function of: importKerasLayers ('ImportWeights',true) to import architecture & Weights
- I have 6 PlaceHolderLayers which are not supported by matlab - in 5 of them I can use transposedConv2dLayer custom layer to replace them
However, I'm not sure how do I import the Weights of those layers into my custom ones. I need them in order to use "assembleNetwork" function that will switch the imported network to a SeriesNetwork object that will be ready to use for prediction.
I followed this flow of work:

回答 (2 件)

Sivylla Paraskevopoulou
Sivylla Paraskevopoulou 2022 年 5 月 9 日
Use the importTensorFlowNetwork function. importTensorFlowNetwork tries to generate a custom layer when you import a custom TensorFlow layer or when the software cannot convert a TensorFlow layer into an equivalent built-in MATLAB layer.
Note that you must first convert your TensorFlow model to the SavedModel format.

Asvin Kumar
Asvin Kumar 2020 年 5 月 26 日
You can use the 'Weights' property for each PlaceholderLayer.
placeholderLayers = findPlaceholderLayers(lgraph);
placeholderLayers(i).Weights
On the other hand, you could explore other parameters involved by checking the data members of the placeholderLayers.KerasConfiguration structure as in this example.
In general, a couple of details in this section might be useful to you.

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by