Effacer les filtres
Effacer les filtres

Neural network output convert to single matrix

4 vues (au cours des 30 derniers jours)
Camila Gill
Camila Gill le 21 Avr 2020
Modifié(e) : Ameer Hamza le 21 Avr 2020
Data file attached.
FIrst, I have two neural networks being tested. I am solving for errors for every iteration. Every iteration produces a unique answer. Once the neural network recalulates for the next iteration, it replaces the prevous solution. I am given only the final solution. I need all iteration solutions in a single column matrix to use for later calculations. How can I combine each answer into a single matrix?
Thought of indexing the results, but I am not sure how to apply it.
Second, how can I determine number of epoch used when trainbr is utilized.
clear
load 'beam_designs_lhs100.mat'; % beam_designs
% Normalize beam models and responses
[beamsin, PS] = mapminmax(beam_designs(:,1:5)');
[beamsout, TS] = mapminmax(beam_designs(:,6:7)');
% 2-layer network
for l1 = 3:5
for l2 = 3:5
% Divide designs into training and test datasets
trainin = beamsin(:,1:600);
trainout = beamsout(:,1:600);
testin = beamsin(:,600+1:end);
testout = beamsout(:,600+1:end);
% Create function fitting neural network
net = fitnet([l1,l2], 'trainlm');
netbr = fitnet([l1,l2], 'trainbr');
net.divideParam.trainRatio = 1;
net.divideParam.valRatio = 0;
net.divideParam.testRatio = 0;
% Train the NN and evaluate its performance
[net, tr] = train(net, trainin, trainout);
[netbr, tr] = train(netbr, trainin, trainout);
outputsD = net(testin(1:5,:));
outputsB = netbr(testin(1:5,:));
perf = perform(net, testout, outputsD); % or use sum of squares
% Computes the sum of squared errors and print results
err_defD = sum((testout(1,:) - outputsD(1,:)).^2);
err_defB = sum((testout(1,:) - outputsB(1,:)).^2);
fprintf('answer %f\n',err_defD) % Dont need, the only way to visualize the solution to each iteration
Anything helps. Thank you.

Réponse acceptée

Ameer Hamza
Ameer Hamza le 21 Avr 2020
Modifié(e) : Ameer Hamza le 21 Avr 2020
You can do indexing like this
count = 1; % define a counter
% 2-layer network
for l1 = 3:5
for l2 = 3:5
and then change these lines
err_defD(count) = sum((testout(1,:) - outputsD(1,:)).^2);
err_defB(count) = sum((testout(1,:) - outputsB(1,:)).^2);
count = count+1;

Plus de réponses (0)

Catégories

En savoir plus sur Sequence and Numeric Feature Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by