Adding layers to narxnet
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/696009/image.png)
Hello everybody, I am currently running into trouble when I try to modify the narxnet example given in the documentation (ph Neutralization process)
While I was able to change activation functions, I#ve run into trouble when adding an additional layer.
The current code:
trainFcn = 'trainlm';
inputDelays = 1:10;
feedbackDelays = 1:10;
hiddenLayerSize = 10;
net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize,'none',trainFcn);
net.inputConnect = [1 1; 0 0];
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net.inputs{2}.processFcns = {'removeconstantrows','mapminmax'};
[x,xi,ai,t] = preparets(net,X,{},T);
net.divideFcn = 'dividerand'; % Divide data randomly
net.divideMode = 'time'; % Divide up every sample
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
net.numlayers = 3; %Add a layer, this sadly also adds more outputs..
net.layers{2}.transferFcn = 'purelin';
net.layers{2}.size = 1;
net.layers{3}.size = 1;
net.layers{3}.transferFcn = 'purelin'; %Double purelin is pointless, but I am just doing this for testing purposes.
net.inputConnect = [1 1; 0 0; 0 0];
net.layerConnect = [0 0 0; 1 0 0; 0 1 0];
net.biasConnect = [1; 1; 1];
net.outputConnect = [0 0 1];
%noloop(net)
net.outputs{3}.feedbackInput = 2; %The third output is addded prior to this by increasing the layer amount.
net.outputs{3}.feedbackMode = 'open';
net.performFcn = 'mse';
net.plotFcns = {'plotperform','plottrainstate', 'ploterrhist', ...
'plotregression', 'plotresponse', 'ploterrcorr', 'plotinerrcorr'};
This sadly adds another output (the real output because net.outputs{1} and net.outputs{2} are just empty.
I think the problem arises from this: net.inputs{2}.feedbackOutput = 2.
But that field is read-only and can't be changed. This creates the unwanted network as seen in the image above. I basically want the ouput to loop to y(t) instead (and have only the two input vectors of course instead of 3 inputs).
If there is anybody with an idea I would be quite happy for help.
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Define Shallow Neural Network Architectures finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!