Error :Index exceeds the number of array elements (1). while generating code for pretrained imported deep neural network

2 ビュー (過去 30 日間)
Hi ,
I am trying to generate C code for a pretrained deep neural network, Network consists of combination input sequential , LSTM , fully connected dense layer and output regreassion layer . The input size of input sequential layer is 7
I wrote the following code for entry level function
function prediction= Trail_predict(InputData)
persistent MyNet;
if isempty(MyNet)
MyNet=coder.loadDeepLearningNetwork('Network.mat');
end
prediction = MyNet.predict(InputData);
end
size(InputData) is 7 1
The function works when i call from the command window
but while checking for issues in matlab coder , i am facing issue Index exceeds the number of array elements (1).
Can someone help me understand what i am doing wrong
  2 件のコメント
Walter Roberson
Walter Roberson 2020 年 9 月 14 日
After the assignment to MyNet, display the class() and size() of MyNet, in order to help debug the problem.
sruthi gundeti
sruthi gundeti 2020 年 9 月 14 日
編集済み: sruthi gundeti 2020 年 9 月 14 日
netclass =
'SeriesNetwork'
netsize =
1 1

サインインしてコメントする。

採用された回答

Vinai Datta Thatiparthi
Vinai Datta Thatiparthi 2020 年 9 月 14 日
Hey Sruthi,
Firstly, it would definitely help if you shared the entire error that you get, and at which stage of your workflow you get the error.
Second, it seems like you're trying to run the example described in the MATLAB documentation for coder.loadDeepLearningNetwork. Here, "the persistent object avoids reconstructing and reloading the network object during subsequent calls to the function to invoke the predict method on the input". In your code, I believe you want to store the persistent SeriesNetwork object as MyNet. If VxNet is what you intended, then it's not described what that means.
Third, it makes sense that netSize is [1 1]: MyNet would be 1x1 SeriesNetwork object. From the description, I understand that you're having trouble predicting the labels of the input data. Can you also verify that when you use the generated MEX to predict labels, you're giving a 7x1 input into the MEX file from Trail_predict?
Hope this helps!
  2 件のコメント
sruthi gundeti
sruthi gundeti 2020 年 9 月 15 日
2.I am really sorry for misguiding with a typo (VxNet) , i am orginally intended to generate code for MyNet .
I am trying to generate code for a keras network which i trained in python and imported the model into python using 'importkerasnetwork' in .json format and with weight file in .h5
3. I am not able to generate mex file but when i give input in commmand window the function works fine, and i am giving the isame input variable as input in the step 2 of the matlab coder

サインインしてコメントする。

その他の回答 (1 件)

sruthi gundeti
sruthi gundeti 2020 年 9 月 17 日
It seems MATLAB Coder doesnt support code generation for sequential layer

カテゴリ

Help Center および File ExchangeDeep Learning with GPU Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by