neural network input error

조회 수: 1 (최근 30일)
Newman
Newman 2016년 11월 28일
답변: Greg Heath 2016년 11월 29일
Hello I want to train my neural network multiple times and track the validation set error.
For the following i am doing this:
First creating the network:
trainFcn = 'trainscg'; % Scaled conjugate gradient backpropagation.
%Create a Pattern Recognition Network
net1 = patternnet(hiddenLayerSize);
%Setup Division of Data for Training, Validation, Testing
net1.divideFcn='dividerand';
net1.divideParam.trainRatio=60/100;
net1.divideParam.valRatio=40/100;
net1.performFcn = 'mse'; % meansquarerror
Then training it:
%Train the Network
for k=1:numel(w_train)
df=w_train(k).f;
[net1,tr] = train(net1,df,target_train);
y=net1(w_train(k).f);
weights_bias(k).w_train=getwb(net1);
valTargets = target_train.*tr.valMask{1};
trueclassindices = vec2ind(target_train);
classes = vec2ind(y);
valcalssindices=tr.valInd;
neval=sum(classes(:,valcalssindices)~=trueclassindices(:,valcalssindices));
PctErrval = 100*neval/length(valcalssindices);
results(k).w_train=PctErrval;
sizes(k).w_train=size(w_train(k).f,1);
end
I am saving the results as well as the weights for every iteration of the input structure w_train(i).f The features in the w_train(i).f are as follows:w_train(1).f = 50x185,w_train(2).f =100x185 and so on.
But after the first iteration i am always getting the same error :
Error using network/train (line 340) Input data size does not match net.inputs{1}.size.
It works clearly with w_train(1).f but not with (2).f or (3).f and so on. Why is this happening ?Please help

채택된 답변

Greg Heath
Greg Heath 2016년 11월 29일
You cannot change the dimension of the inputs from 50 to 100;
Hope this helps
Thank you for formally accepting my answer
Greg

추가 답변 (0개)

카테고리

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