When I try to load a keras model using importKerasNetwork I get the following error (R2020A)

조회 수: 1 (최근 30일)
When I try to load a keras model using importKerasNetwork I get the following error (this is in R2020A).
Brace indexing is not supported for variables of this type.
Error in nnet.internal.cnn.keras.readModelAndTrainingConfigs>iVerifyKerasBackend
(line 71)
if ~isequal(BackendCell{1}, 'tensorflow')
Error in nnet.internal.cnn.keras.readModelAndTrainingConfigs (line 8)
iVerifyKerasBackend(ConfigFile);
Error in nnet.internal.cnn.keras.importKerasNetwork (line 21)
[ModelConfig, TrainingConfig, KerasVersion] =
nnet.internal.cnn.keras.readModelAndTrainingConfigs(ConfigFile, Format);
Error in importKerasNetwork (line 91)
Network = nnet.internal.cnn.keras.importKerasNetwork(modelfile, varargin{:});
Error in LoadingEyetoneIntoMatlab (line 4)
net=importKerasNetwork(sprintf('%s%s', modelpath,networkname));

답변 (1개)

Sourabh Kondapaka
Sourabh Kondapaka 2020년 11월 17일
In the below line:
net=importKerasNetwork(sprintf('%s%s', modelpath,networkname));
Between the '%s' and '%s' , you'll need to add a '/' .
Although this is not an ideal approach, you can do something like this:
modelPath = fileparts(which(modelName));
net = importKerasnetwork([modelPath filesep modelName '.h5']); %Assuming your model has .h5 extension
To learn more about the functions used above, refer the following links:
  댓글 수: 1
Alexander Berardino
Alexander Berardino 2020년 11월 17일
편집: Alexander Berardino 2020년 11월 17일
Hi Sourabh,
Thanks for your response. The error is not actually in the file path (the pathname variables in the error I copied above have '/' in the correct place.)
I tried your version, and I get the same error. It appears there is an error in nnet.internal.cnn.keras.readModelAndTrainingConfigs>iVerifyKerasBackend here if ~isequal(BackendCell{1}, 'tensorflow'), but when inspecting BackendCell, it appears that BackendCell is not a cell array, but rather a character array that says 'tensorflow'.
It seems as though there is a mismatch between the way that character array is being loaded in and what the matlab function is expecting.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by