NARX DNN: hidden layers and activation function
6 views (last 30 days)
Show older comments
Hi there, can you please tell me how to set the number of hidden layers and the activation function of the output layer in a NARX network? It seems that I can only use one hidden layer and the linear function in the output layer.
0 Comments
Answers (1)
Adarsh
on 23 Jan 2025
Hi,
I am assuming by NARX DNN you are referring to the “narxnet” Network. From what I found in the MATLAB documentation, in the “narxnet” Network the number of hidden layers in the Network can be modified by passing a row vector of one or more hidden layer sizes as input and as for the output layer activation function part you can access the last layer through the object handle of the “narxnet” object created and change its “transferFcn” property to any other function from “purelin” (linear activation). Here is an example code on how to use multiple hidden layers and modify output layer activation function:
net = narxnet(1:2,1:2,[10 2]); % Input delays, Feedback delays, Hidden layers row vector
[Xs,Xi,Ai,Ts] = preparets(net,XTrain,{},TTrain); % Preparing time series data
net.layers{end}.transferFcn = "logsig"; % Modifying the output layer activation function
net = train(net,Xs,Ts,Xi,Ai); % Train the network
Here is the link to the documentation section regarding the usage of “narxnet” with multiple hidden layers:
I hope it helps !
0 Comments
See Also
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!