predict DAGnetwork error in compiled .exe

4 visualizaciones (últimos 30 días)
Gavin Robertson
Gavin Robertson el 12 de En. de 2018
Respondida: Tao Cui el 24 de Nov. de 2019
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 comentario
Don Mathis
Don Mathis el 1 de Mzo. de 2018
Could you post some lines of code that I can paste into MATLAB that will let me replicate the problem?

Iniciar sesión para comentar.

Respuestas (3)

Raymond Lei
Raymond Lei el 23 de Feb. de 2018
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 el 25 de Jul. de 2018
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 comentario
Oleksii Sidorov
Oleksii Sidorov el 25 de Jul. de 2018
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)

Iniciar sesión para comentar.


Tao Cui
Tao Cui el 24 de Nov. de 2019
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

Categorías

Más información sobre Deep Learning Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by