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')

답변 (2개)

Greg Heath
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
Reff 2020년 4월 19일
hi,
what is means of paramater?
  1. sweep=[3,5:5:50]; %parameter values to test
  2. scores=zeros(length(sweep),1); %pre-allcation
  3. models=cell(length(sweep),1); %pre-allcation

카테고리

Help CenterFile 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!

Translated by