how to rewrite this for feedforward neural network for with 52 inputs and 2 output that predict emission rate not for digits, where i get an error of In an assignment A(:) = B, the number of elements in A and B must be the same. Error in line36
2 ビュー (過去 30 日間)
古いコメントを表示
sweep=[3,5:5:50]; %parameter values to test
scores=zeros(length(sweep),1); %pre-allcation
models=cell(length(sweep),1); %pre-allcation
load('inputs.mat');
load('outputs.mat');
load('newinputs.mat');
load('newoutputs.mat');
in=inputs; % loads inputs into variable 'in'
t=outputs; % loads outputs into variable 't'
in_test=newinputs; % loads test inputs into variable 'in_test'
t_test=newoutput; % loads test inputs into variable 't_test'
%training function:
net.trainFcn = 'trainlm';
%transfer functions:
net.layers{1}.transferFcn = 'tansig';
net.layers{2}.transferFcn = 'purelin';
net.trainParam.epochs = 100000;
for i=1:length(sweep)
hiddenlayersize=sweep(i); %number of hidden layer neurons
net=patternnet(hiddenlayersize);
net.divideFcn = 'dividerand'; % Divide data randomly
net.divideMode = 'sample'; % Divide up every sample
net.divideParam.trainRatio=0.7;
net.divideParam.valRatio=0.15;
net.divideParam.testRatio=0.15;
%training the network
net = train(net,in,t);
%simulating the outputs
y=sim(net,in);
%store the trained network
models{i}=net;
%prediction to test the network
pre=net(in_test);
%prediction labels
scores(i)=sum(t_test==pre)/length(t_test); %accuracy
end
%plot accuracy versus number of neorons in the hidden layer
figure
plot(sweep,scores,'.-')
xlabel('number of hidden neurons')
ylabel('accuracy')
title('number of hidden neurons vs.accuracy')
0 件のコメント
回答 (2 件)
Greg Heath
2018 年 12 月 30 日
編集済み: Greg Heath
2019 年 1 月 3 日
Replace the " == " in
scores(i)=sum(t_test==pre)/length(t_test); %accuracy
with a minus sign
WHOOPS !!!
I misread the text. I was thinking of an error measure to minimize of the form
errorscore(i) = sum( abs( t_test - pre )/ length(t_test) )
Hope this helps.
*Thank you for formally accepting my answer*
Greg
Reff
2020 年 4 月 19 日
hi,
what is means of paramater?
- sweep=[3,5:5:50]; %parameter values to test
- scores=zeros(length(sweep),1); %pre-allcation
- models=cell(length(sweep),1); %pre-allcation
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Sequence and Numeric Feature Data Workflows についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!