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 visualizaciones (últimos 30 días)
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')

Respuestas (2)

Greg Heath
Greg Heath el 30 de Dic. de 2018
Editada: Greg Heath el 3 de En. de 2019
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 el 19 de Abr. de 2020
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

Categorías

Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by