Generating a graph from neural network

Hi. How to generate a graph from neural network train tool?
Let say for y-axis = MSE and Accuracy, x-axis = number of neuron.
Thanks in advance.

 Risposta accettata

I think if you want to use neural network train tool, then you will need to configure each network separately and save their accuracy and MSE values. It will be easier if you write the code to train your network and then use a for-loop to try different numbers of neurons. Following code shows an example
[x,t] = simplefit_dataset;
N = [1 2 3 5 10 20]; % number of neurons to try
MSE = zeros(size(N));
for i=1:numel(N)
net = feedforwardnet(N(i));
net = train(net, x, t);
y = net(x);
MSE(i) = perform(net,y,t);
end
plot(N, MSE);
xlabel('Neurons');
ylabel('MSE');

4 Commenti

Hi ameera hamzah,
i try to combine my script with your answe, but still have error.
The error is Error: An array for multiple LHS assignment cannot contain expressions.
my mse result is 0.1012. how to reduce a mse result to lowest value such as 0.001
close all;
clc;
clear all;
a = load ('BA.txt');
b = load ('TARGET.txt');
inputs = a';
targets = b';
% Create a Pattern Recognition Network
hiddenLayerSize = 5;
net = patternnet(hiddenLayerSize)
%
% % Set up Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 20/100;
net.divideParam.testRatio = 10/100;
% net.performFcn = 'mse';
% % Set up Division of Data for Training, Validation, Testing
% net.trainParam.trainRatio = 70/100;
% net.trainParam.valRatio = 15/100;
% net.trainParam.testRatio = 15/100;
% Train the Network
net.trainFcn='trainlm'%training pattern
[net,tr] = train(net,inputs,targets);
% Test the Network
outputs = net(inputs);
errors = gsubtract(targets,outputs);
% performance = perform(net,targets,outputs)
MSE = mse(net,targets,outputs)
net.performFcn = 'mse';
% View the Network
view(net)
[a',b'] = simplefit_dataset;
N = [5 10 15 20 25 30]; % number of neurons to try
MSE = zeros(size(N));
for i=1:numel(N)
net = feedforwardnet(N(i));
net = train(net, a', b');
y = net(a');
MSE(i) = perform(net,y,b');
end
plot(N, MSE);
xlabel('Neurons');
ylabel('MSE');
Which line gives this error? What are the dimensions of the matrices a and b? Only way to decrease MSE is to increase the number of neurons.
error line at [a',b'] = simplefit_dataset;
dimension matrix a & b are
a: 9x60
b:9x1
Reff, I added this line
[a',b'] = simplefit_dataset;
to load an example dataset. If you already have variables a and b then try to run this code after removing this line.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by