How to add 2 or more hidden layer to the neural network?
3 views (last 30 days)
Show older comments
I have this code i need to add 2 hidden layer, can anyone please help me with that please. Here is the code
[J,grad] = netcost(nn_params,input_layer_size,hidden_layer_size,num_labels,X, y, lambda)
Theta1 = reshape(nn_params(1:hidden_layer_size * (input_layer_size + 1)), ... hidden_layer_size, (input_layer_size + 1));
Theta2 = reshape(nn_params((1 + (hidden_layer_size * (input_layer_size + 1))):end), ... num_labels, (hidden_layer_size + 1));
num_labels=2; 1 hidden layer; input neurons=2160,hidden layer neuron=20; I want to add totally 2 hidden layers, please can anyone help me with the code please
9 Comments
Philip G
on 20 Apr 2017
Edited: Philip G
on 20 Apr 2017
Just executing the command
net=feedforwardnet([200 200 200]);
Does not give any errors and will give you a network with 3 hidden layers of size 200 (see attached image). I am not sure what your error is. Also in the code above "netcost" is not a MATLAB function - so it is hard to say where your error comes from (especially this strange behavior that you can not create a network with a layer size bigger than 100).
Answers (0)
See Also
Categories
Find more on Define Shallow Neural Network Architectures 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!