mkl-dnn code generation failed with Index exceeding error

3 views (last 30 days)
Hi, I'm trying to make mex function with my pretrained network.
But I ran into this error msg:
??? Error generating code for network net_0. Index exceeds the number of array elements (0).
My SeriesNetwork object has layers as:
1 'input_6' Image Input 1x1x2 images
2 'conv2d_transpose_8' Transposed Convolution 32 4x4x2 transposed convolutions with stride [4 4] and cropping 'same'
3 'batch_normalization_20' Batch Normalization Batch normalization with 32 channels
4 're_lu_8' ReLU ReLU
5 'conv2d_transpose_9' Transposed Convolution 64 4x4x32 transposed convolutions with stride [2 2] and cropping 'same'
6 'batch_normalization_21' Batch Normalization Batch normalization with 64 channels
7 're_lu_9' ReLU ReLU
8 'conv2d_transpose_10' Transposed Convolution 128 4x4x64 transposed convolutions with stride [2 2] and cropping 'same'
9 'batch_normalization_22' Batch Normalization Batch normalization with 128 channels
10 're_lu_10' ReLU ReLU
11 'conv2d_transpose_11' Transposed Convolution 256 4x4x128 transposed convolutions with stride [2 2] and cropping 'same'
12 'batch_normalization_23' Batch Normalization Batch normalization with 256 channels
13 're_lu_11' ReLU ReLU
14 'conv2d_14' Convolution 1 4x4x256 convolutions with stride [1 1] and padding 'same'
15 'conv2d_14_tanh' Tanh Hyperbolic tangent
And I have a function:
function out = microstructure_generator(in)
persistent net
if isempty(net)
net = coder.loadDeepLearningNetwork('MSGen_z2_no_cond.mat', 'net');
end
out = net.predict(in);
Finally, I executed the following commands just like in the example above.
cfg = coder.config('mex');
cfg.TargetLang = 'C++';
cfg.DeepLearningConfig = coder.DeepLearningConfig('mkldnn');
codegen -config cfg microstructure_generator -args {ones(1,1,2,'single')} -report
I tried with adding an output layer or something, but nothing worked.
I think the error msg does not have enough information about the error. I don't get the reason for this. Please help me...

Answers (1)

Chaitanya Mallela
Chaitanya Mallela on 9 Mar 2020
Save the DAG network as .mat file
Try Codegen by modifying isempty function
function out = microstructure_generator(in)
persistent net
if isempty(net)
net = coder.loadDeepLearningNetwork('MSGen_z2_no_cond.mat');
end
out = net.predict(in);

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!