Why wont a seriesnetwork object compile in Simulink?

2 次查看(过去 30 天)
I have trained a sequence to sequence LTSM deep classification network with the veiw of implementing it in simulink to classify EEG data coming in timesteps. The networks has the following layers and options shown in the below code. Im able to classify new data in matlab using classifyAndUpdateState(net,timestepdata) like shown in the code below.
However once I use the classify function inside a simulink program to classify new incoming data (coming in the same format as the trained network) the program wont compile as it does not recognise the net object. How can I get around this or alternatively how can I implement the trained LTSM net in Simulink. (obviously cant use gensim etc for a series network)
layers = [ ...
sequenceInputLayer(20)
bilstmLayer(100,'OutputMode','sequence')
bilstmLayer(100,'OutputMode','sequence')
bilstmLayer(100,'OutputMode','sequence')
bilstmLayer(100,'OutputMode','sequence')
fullyConnectedLayer(3)
softmaxLayer
classificationLayer
]
%%
options = trainingOptions('adam', ...
'MaxEpochs',300, ...
'InitialLearnRate', 0.01, ...
'GradientThreshold', 1, ...
'plots','training-progress', ...
'Verbose',false, ...
'ValidationData',{XTestReady,YTestReady}, ...
'ValidationFrequency',1);
%for classifying new data in timesteps
for i = 1:numTimeSteps
v = X(:,i);
[net,label,score] = classifyAndUpdateState(LTSMnet,v);
labels(i) = label;
end
  1 个评论
Prajith Chilummula
Prajith Chilummula 2019-1-11
You can save the 'net' variable in a mat file and load the mat file in the MATLAB function and use the function as MATLAB function block.
Also please refer the below link:
https://www.mathworks.com/matlabcentral/answers/40701-using-workspace-data-in-matlab-function-block-simulink

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by