필터 지우기
필터 지우기

How to add 2 or more hidden layer to the neural network?

조회 수: 5 (최근 30일)
Tousif Ahmed
Tousif Ahmed 2017년 4월 15일
댓글: Tousif Ahmed 2017년 4월 20일
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
Philip G
Philip G 2017년 4월 20일
편집: Philip G 2017년 4월 20일
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).
Tousif Ahmed
Tousif Ahmed 2017년 4월 20일
i will post the code here. please have a look.
load latest.mat; trainFcn = 'trainscg'; % Scaled conjugate gradient backpropagation.
net.performFcn = 'mse'; %newly added
hiddenLayerSize = 10; %net = patternnet(hiddenLayerSize); net=feedforwardnet([50 10]);
view (net); net.divideParam.trainRatio = 70/100; net.divideParam.valRatio = 15/100; net.divideParam.testRatio = 15/100;
net.trainParam.epochs = 100;
[net,tr] = train(net,training,test); y = net(training); e = gsubtract(test,y); performance = perform(net,test,y) tind = vec2ind(test); yind = vec2ind(y); percentErrors = sum(tind ~= yind)/numel(tind);
net.IW{1,1}; net.b{1}; %net.LW {1};
% View the Network view(net)
I have attached the file named 'latest.mat'.It contains image file of size 27x18, 11 images for training and 2 images for test. I dont know whether the procedure i have followed to add the images for training and test are correct. Please correct me if i am wrong and please have a look

댓글을 달려면 로그인하십시오.

답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by