dimanche 16 mai 2021

Matlab: "Error using randperm K must be less than or equal to N." even though K <= N?

dataFolderTrain = fullfile(PATH);

imdsTrain = imageDatastore(dataFolderTrain, ...
    'IncludeSubfolders',true, ...
    'LabelSource','foldernames');


idxs = randperm(numel(imdsTrain.Files),8);


batchSize = 10;
[pairImage1,pairImage2,pairLabel] = getSiameseBatch(imdsTrain,batchSize);

I am trying to implement my own Siamese Network. The full error is:

Error in SiameseTrainMine>getSimilarPair (line 357)
    pairIdxChoice = randperm(numel(idxs),2);

Error in SiameseTrainMine>getSiameseBatch (line 334)
            [pairIdx1,pairIdx2,pairLabels(i)] = getSimilarPair(imds.Labels);

Error in SiameseTrainMine (line 22)
[pairImage1,pairImage2,pairLabel] = getSiameseBatch(imdsTrain,batchSize);

However if I type "randperm(numel(idxs),2)" into the console it works fine and "numel(idxs)" returns 8




Aucun commentaire:

Enregistrer un commentaire