Neural network output convert to single matrix

2 ビュー (過去 30 日間)
Camila Gill
Camila Gill 2020 年 4 月 21 日
編集済み: Ameer Hamza 2020 年 4 月 21 日
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.

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 21 日
編集済み: Ameer Hamza 2020 年 4 月 21 日
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;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by