Index exceeds the number of array elements (20) Error
Mostrar comentarios más antiguos
cvx=cvpartition(size(Features,1),'kfold',5);
numvalidsets = cvx.NumTestSets;
n = cvx.TrainSize(1);
lambdavals = linspace(0,20,20)/n;
lossvals = zeros(length(lambdavals),numvalidsets);
for w = 1:length(lambdavals)
for p =1:numvalidsets
train=1;
test=1;
indextrain=training(cvx,p);
for i=1:size(Features,1)
if indextrain(i)==1
XTrain(train,:)=Features(i,:);
YTrain(train)=label(i);
train=train+1;
else
XTest(test,:)=Features(i,:);
YTest(test)=label(i);
test=test+1;
end
end
TrainData= XTrain,YTrain;
TestData =XTest,YTest;
nca = fscnca(XTrain,YTrain,'FitMethod','exact', ...
'Solver','sgd','Lambda',lambdavals(i), ...
'IterationLimit',30,'GradientTolerance',1e-4, ...
'Standardize',true);
lossvals(w,p) = loss(nca,XTest,YTest,'LossFunction','classiferror');
end
end
i recived this error ''Index exceeds the number of array elements (20).'' the error is from the fourth line ''lambdavals = linspace(0,20,20)/n;''
as the feature size is 700x16384 single and label size is 1x700 double. any help how to set the linspace () parameters i will be approchated.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Matrices and Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!