neural network input error

1 次查看(过去 30 天)
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