How do I solve the "Referene to non-existent field" error when importing a Tensorflow model?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello everyone,
this is my first question on this forum.
I worked for a while in python (Tensorflow) on a simple classification network from my research (I'm a PhD student) and now I'd like to import it in Matlab (I need it in both the frameworks). I did some research and I found the
importKerasNetwork
importKerasLayers
functions in the Deep Learning Toolbox which should solve my problem. Sadly, I was using Keras 2.3.0 in my model (Tensorflow 2.2.0) and I kept getting this warning:
Warning: File '2020_06_19_11_49_10.h5' was saved in Keras version '2.3.0-tf'. 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.
together with the following error:
Reference to non-existent field 'dense_2'.
The first question is: can I do something to still use this model in Matlab?
I decided to go back to Keras 2.2.4 (with Tensorflow 2.1.0) and to re-train my network. Before doing this I decided to try and convert a simple non-trained network (some conv2d, max pooling, dense) but I still got the same error (not the warning, of course):
Reference to non-existent field 'dense_1'.
What am I doing wrong?
Thank in advance for the help,
Diego
UPDATE
This is not only a problem of the dense layer, it also happens when I remove the dense layers from my model, the error simply goes to another kind of layer.
댓글 수: 0
답변 (1개)
Sivylla Paraskevopoulou
2022년 4월 27일
편집: Sivylla Paraskevopoulou
2022년 4월 27일
You can try to use the importTensorFlowNetwork function, which was introduced in R2021a. importTensorFlowNetwork supports newer TensorFlow versions, imports TensorFlow models in savedModel format, and tries to generate a custom layer when the software cannot convert a TensorFlow layer into an equivalent built-in MATLAB layer.
댓글 수: 0
참고 항목
카테고리
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!