Undefined function or variable error using Neural Network Toolbox

I am following the provided example for Long-Short-Term-Memory networks found in the Neural Network Toolbox (https://de.mathworks.com/help/nnet/examples/classify-sequence-data-using-lstm-networks.html) and whenever I use the code given in the example for training the network
net = trainNetwork(X,Y,layers,options);
I get the following error:
>> net = trainNetwork(X,Y,layers,options);
Training on single GPU.
|=========================================================================================|
| Epoch | Iteration | Time Elapsed | Mini-batch | Mini-batch | Base Learning|
| | | (seconds) | Loss | Accuracy | Rate |
|=========================================================================================|
Error using trainNetwork (line 140)
Undefined function or variable 'endfunction'.
Caused by:
Undefined function or variable 'endfunction'.
I tried re-installing the toolbox and rehasing the toolbox cache but it does not matter. Also, if I try to use
maxEpochs = 150;
miniBatchSize = 27;
shuffle = 'never';
cpu = 'cpu';
options = trainingOptions('sgdm', ...
'MaxEpochs',maxEpochs, ...
'MiniBatchSize',miniBatchSize, ...
'Shuffle', shuffle), 'ExecutionEnvironment' , cpu);
I get this error message:
>> net = trainNetwork(X,Y,layers,options);
Error using trainNetwork (line 140)
Undefined function or variable 'endfunction'.
Caused by:
Undefined function or variable 'endfunction'.
It looks like while using the CPU for computation the function does not even start.
Thanks in advance.

 採用された回答

Walter Roberson
Walter Roberson 2017 年 10 月 27 日

1 投票

endfunction is for Octave code not MATLAB

4 件のコメント

Walter Roberson
Walter Roberson 2017 年 10 月 31 日
It is possible that you have an octave function on your path that happens to have the same name as one of the Mathworks functions and so you could accidentally be invoking the wrong code.
To track this down you would
dbstop if caught error
and then run trainNetwork . You might have to dbcont a couple of times to get to the place where endfunction is being encountered.
Burak Özbagci
Burak Özbagci 2017 年 11 月 2 日
Thank you that was it. I removed any conflicting Octave codes found in my path. Now it works.
Akib Rahman
Akib Rahman 2018 年 6 月 22 日
編集済み: Akib Rahman 2018 年 6 月 22 日
@Walter I am facing same type problem! I also use your suggestion ( dbstop if caught error ) but it is same. What should I do? In my PC neural network toolbox already installed.
When I run my code it gives me this error
Undefined function or variable 'batchNormalizationLayer'.
Error in leafRNN (line 30)
batchNormalizationLayer
Walter Roberson
Walter Roberson 2018 年 6 月 22 日
batchNormalizationLayer needs R2017b or later.

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

その他の回答 (1 件)

Shounak Mitra
Shounak Mitra 2017 年 10 月 31 日
編集済み: Walter Roberson 2017 年 10 月 31 日

0 投票

options = trainingOptions('sgdm', ...
'MaxEpochs',maxEpochs, ...
'MiniBatchSize',miniBatchSize, ...
'Shuffle', shuffle), 'ExecutionEnvironment' , cpu);
You might want to remove the bracket after shuffle? ;-)

カテゴリ

ヘルプ センター および File ExchangeDeep Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by