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';
net1 = patternnet(hiddenLayerSize);
net1.divideFcn='dividerand';
net1.divideParam.trainRatio=60/100;
net1.divideParam.valRatio=40/100;
net1.performFcn = 'mse';
Then training it:
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