Error in transferring a neural net as function argument
조회 수: 11 (최근 30일)
이전 댓글 표시
Hi, dears
I have generated a library of VC++ using 'deploytool', which includes some functions that creates and trains a neural net.
All functions perform correctly in matlab. I call functions in C++ code.
The function which recieves the created neural net as its argument fails in run.
Error using *
MTIMES (*) is not fully supported for integer classes. At least one argument must be scalar.
Error in dotprod.apply (line 6)
Error in nnMATLAB.backpropJacobianStatic (line 67)
Error in nnMATLAB.perfsJEJJ (line 11)
Error in nnCalcLib/perfsJEJJ (line 388)
Error in trainlm>initializeTraining (line 173)
Error in nnet.train.trainNetwork>trainNetworkInMainThread (line 28)
Error in nnet.train.trainNetwork (line 16)
Error in trainlm>train_network (line 164)
Error in trainlm (line 63)
Error in network/train (line 369)
Error in TrainNN (line 6)
note: It is needed to createNN() and TrainNN() be seperated functions.
Matlab Functions
function net=CreateNN(inp,outp)
inp=inp';
outp=outp';
net=network(1,2,[1;1],[1;0],[0 0;1 0],[0 1]);
net.layers{1}.size=50;
net.layers{1}.transferFcn='logsig';
net.layers{2}.size=1;
net.layers{2}.transferFcn='purelin';
net.trainFcn='trainlm';
net.performFcn='mse';
net=configure(net,inp,outp);
msgbox('NN was created successfully');
end
function net=TrainNN(net,inp,outp)
inp=inp';
outp=outp';
net=network(net);
msgbox(class(net));% to ensure type is 'network'
net=train(net,inp,outp);
msgbox('terminate traning');
end
C++ code:
int inp[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int outp[2] = { 10, 20 };
mwArray inpv(1, 10, mxINT16_CLASS);
mwArray outpv(1, 2, mxINT16_CLASS);
outpv.SetData(outp, 2);
inpv.SetData(inp, 10);
mwArray net;
CreateNN(1, net, inpv, outpv);
TrainNN(1, net, net, inpv, outpv); % error occurs
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Deploy to C++ Applications Using mwArray API (C++03)에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!