How is the output layer characterized in the neural network toolbox?

1 view (last 30 days)
Hello everyone,
I have created a neural network with one hidden layer and one output layer. Overall there are two input elements and 24 output elements. I am working with 10 hidden neurons in the hidden layer.
Now when I run view(net) the graphical overview shows me that I have two input elements, 10 hidden neurons in the hidden layer and 24 output elements. The graphic also shows me the output layer. Under the output layer the number 11 is displayed..
What does this number stand for? Is it a number for the output neurons? Why isn't it 24 then? Until now I always worked with neural networks with only one output. When running view(net) with those networks there was always the number 1 displayed under the output layer...
Thanks alot!

Accepted Answer

Greg Heath
Greg Heath on 5 Feb 2015
Your code looks ok. However, since the figure shows 3 inputs, I question your quoted sizes. Insert the following statements
inputs = input % this is a 2x194 matrix
targets = target; % this is a 24x194 matrix
[ I N ] = size(inputs)
[ O N ] = size(targets)
...
[net_cloudy, tr] = train(net_cloudy, inputs, targets);
view(net_cloudy)
...
whos % check cell and double sizes
Hope this helps.
Thank you for formally accepting my answer
Greg

More Answers (1)

Greg Heath
Greg Heath on 8 Oct 2014
It works for me. You will have to show your code.
Greg
  2 Comments
MC3105
MC3105 on 8 Oct 2014
Edited: MC3105 on 8 Oct 2014
Actually I have three different neural networks my code. My goal is to predict the future power production of wind turbines in Northern Germany. To do that I train three different networks: one for sunny weather, one for partly cloudy weather and one for cloudy weather. Each network is trained by different input data: The network for sunny weather is for example trained by input values that were measured during sunny days while the network for cloudy weather is trained by input values that were measured during cloudy days etc. For each network I have input matrices with 2 rows (one row for each input element) and x columns (for x sunny/partlycloudy/cloudy days in my training dataset). The target matrix has 24 rows (for each hour of the predicted day) and x columns (for x sunny/partly/cloudy days in my training set). Now when I run the networks I get this:
For the first neural network my input matrix is 2X194 while my target matrix is 24x194. I am working with 10 hidden neurons. The graphical overview shows me 2 input elements, 10 hidden neurons, a variable number of neurons in the output layer (apparently the number of neurons in the output layer changes when I change the origin of my input date. When I use input data that comes from a location that corresponds to a offshore wind turbine far out in the ocean I get 11 neurons in the output layer. When I use input date that corresponds to a onshore wind turbine on the main land I get 14 neurons in the output layer) and 24 output elements. This is my code:
%%Neural Network for cloudy days
inputs = input % this is a 2x194 matrix
targets = target; % this is a 24x194 matrix
%%Architecture of the network
hiddenLayerSize = 10;
net_cloudy = fitnet(hiddenLayerSize);
% Input and Output pre-/postprocessing functions
net_cloudy.inputs{1}.processFcns = {'removeconstantrows','mapminmax'};
net_cloudy.outputs{2}.processFcns = {'removeconstantrows','mapminmax'};
% Selection of internal transfer functions
net_cloudy.layers{1}.transferFcn = 'tansig';
net_cloudy.layers{2}.transferFcn = 'purelin';
% Selection of training algorithm
net_cloudy.trainFcn = 'trainlm';
% Division of data into training, validation and test data set
net_cloudy.divideFcn = 'dividerand'; % Zufällige Aufteilung der Daten
net_cloudy.divideMode = 'sample'; % Aufteilung jeder Stichprobe
net_cloudy.divideParam.trainRatio = 70/100;
net_cloudy.divideParam.valRatio = 20/100;
net_cloudy.divideParam.testRatio = 10/100;
% Selection of mean squard errors for performance measurement
net_cloudy.performFcn = 'mse';
% Training the network
[net_cloudy,tr] = train(net_cloudy,inputs,targets);
% Testing the network
outputs_cloudy = net_cloudy(inputs);
errors_cloudy = gsubtract(targets,outputs_cloudy);
performance = perform(net_cloudy,targets,outputs_cloudy);
% Performance calculation
trainTargets = targets .* tr.trainMask{1};
valTargets = targets .* tr.valMask{1};
testTargets = targets .* tr.testMask{1};
trainPerformance_cloudy = perform(net_cloudy,trainTargets,outputs_cloudy);
valPerformance_cloudy = perform(net_cloudy,valTargets,outputs_cloudy);
testPerformance_cloudy = perform(net_cloudy,testTargets,outputs_cloudy);

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!