How to randomize the order of training images of a CNN?
조회 수: 5 (최근 30일)
이전 댓글 표시
Jaime Almonacid-Caballer
2020년 9월 17일
댓글: Jaime Almonacid-Caballer
2020년 9월 18일
Dear masters of Matlab,
I am training a Convolutional Neural Network (CNN). and I cannot change the order of the images in the training set. Let's see if I can explain the problem.
- 1. About the training set
The training set is given so that the folders are the classes to be used:
Train_imds = imageDatastore(fullfile(TrainFolder, categories), ...
'LabelSource', 'foldernames');
It gives the next structure:
I have 56341 images to train 10 classes.
The images are order by each class. All the images of class "A" are in first position, secondly the images of class "B" all together, etc. I would like to randomize these order.
- 2. Effect of this order in the training
When I run trainNetwork, each iteration takes part of these images until every image has "passed through" the net. Some iterations will be training only one class before the next class begins. I would like to randomize this order so that becomes more probable that every class trains each iteration.
- 3. Failed attempts
If I change Folders{} , the Labels{} change to empty.
If I make a copy so that I can change the structure, both structures change.
Any help will be welcomed. Thanks a lot
댓글 수: 0
채택된 답변
Mohammad Sami
2020년 9월 18일
편집: Mohammad Sami
2020년 9월 18일
if isShuffleable(Train_imds)
newds = shuffle(Train_imds);
disp('Shuffling successful.')
else
disp('Datastore is not shuffleable.')
end
A second option is to enable shuffling in the training options.
solverName = 'sgdm'; % choose your solver
options = trainingOptions(solverName,'Shuffle','every-epoch');
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!