필터 지우기
필터 지우기

predict DAGnetwork error in compiled .exe

조회 수: 8 (최근 30일)
Gavin Robertson
Gavin Robertson 2018년 1월 12일
답변: Tao Cui 2019년 11월 24일
I'm hoping someone can shed light on an error I'm encountering.
I have a trained Keras model that I have imported using:
if true
net = importKerasNetwork(modelfile,'WeightFile',weights)
end
and I can make predictions on image patches with no errors from the command line with:
if true
prediction = predict(net,imagePatch);
end
I can also save and load the network to make predictions.
However, when I try to use these lines a standalone .exe I run into errors that I don't know how to solve.
When I try loading the saved network to make predictions I encounter the following:
if true
Warning: During load:
An invalid default object has been detected while loading a heterogeneous array of class nnet.cnn.layer.Layer.
An empty array of class nnet.cnn.layer.Layer will be returned.
Warning: While loading an object of class 'DAGNetwork':
Subscript indices must either be real positive integers or logicals.
end
I have some error catching in my code and the exception is:
if true
"identifier": "MATLAB:structRefFromNonStruct",
"message": "Struct contents reference from a non-struct array object."
"stack": [
"file": "\\mcrCache9.3\\optoma0\\toolbox\\nnet\\cnn\\DAGNetwork.m",
"name": "DAGNetwork.predict",
"line": 387
end
If I try to use importKerasNetwork instead of loading the saved network I get the following error:
if true
"identifier": "MATLAB:internal:msgcat:msgcatInvalidResourcePath",
"message": "The path \\mcrCache9.3\\optoma1\" is not a valid message catalog
resource path",
"cause": [],
"stack": [
[
{
"file": "\\mcrCache9.3\\optoma1\\toolbox\\nnet\\supportpackages\\keras_importer\\importKerasNetwork.m",
"name": "importKerasNetwork",
"line": 70
end
  댓글 수: 1
Don Mathis
Don Mathis 2018년 3월 1일
Could you post some lines of code that I can paste into MATLAB that will let me replicate the problem?

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

답변 (3개)

Raymond Lei
Raymond Lei 2018년 2월 23일
I've encountered the same problem executing the compiled java library, same error messages for both cases. Please have a look at this problem!

Oleksii Sidorov
Oleksii Sidorov 2018년 7월 25일
I faced the same issue installing Inception-ResNet-v2,
most probably it is caused by the fact that definition of DAGNetwork contains layers which are NOT default in NN Toolbox. These "new" layers are downloaded and installed together with add-on. So, logically, without them network model has a "reference" on layers which are not exist.
I solved this issue by copying whole add-on's directory and running inceptionresnetv2.m file instead of just loading data from inceptionresnetv2.mat. In this way model is imported together with layers.
  댓글 수: 1
Oleksii Sidorov
Oleksii Sidorov 2018년 7월 25일
You also need to copy that custom layers to your working dir, and add it to matlab path like following:
exampleFolder = genpath(fullfile(pwd));
addpath(exampleFolder)

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


Tao Cui
Tao Cui 2019년 11월 24일
You can do this:
In the compiler interface click that "Settings" logo. In settings, copy and paste the following string to that "Additional parameters passed to MCC".
-a 'C:\ProgramData\MATLAB\SupportPackages\R2018a\toolbox\nnet\supportpackages\keras_importer'
Assuming you are using R2018a.
CaptureMat.PNG

Community Treasure Hunt

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

Start Hunting!

Translated by