Retraining Alexnet - works on windows 7 not on windows 10?
조회 수: 1(최근 30일)
표시 이전 댓글
James Silk 2022년 4월 1일
댓글: Joss Knight 2022년 4월 4일
I wrote the below code a few years ago on a windows 7 machine and it works quite well on the data set provided. I have recently tried resuing it on a new windows 10 machine and, while the code runs, it only gets a 20% accuracy as it just guesses the same label each time.
In both instances the code is identical, both using matlab 2019b and both using the same set of images. Slightly confused as to why this is happening any help would be appreciated.
It does also show this warning which seems to slow it down more on the windows 10 machine: Warning: The CUDA driver must recompile the GPU libraries because your device is more recent than the libraries. Recompiling can take several minutes. Learn more.
folder = 'Roads';
road_ds = imageDatastore(folder,'IncludeSubfolders',true,'LabelSource',"foldernames");
roadlabels = road_ds.Labels;
net = alexnet;
[roadTrain, roadTest] = splitEachLabel(road_ds,0.6);
roadTrain_auds = augmentedImageDatastore([227 227 3],roadTrain,'ColorPreprocessing','gray2rgb')
roadTest_auds = augmentedImageDatastore([227 227 3],roadTest,'ColorPreprocessing','gray2rgb')
layers = net.Layers;
inputlayer = imageInputLayer([227 227 3],'Name','input')
fc = fullyConnectedLayer(5);
layers(23) = fc;
layers(end) = classificationLayer;
options = trainingOptions('sgdm','InitialLearnRate', 0.001,'Plots',"training-progress",'MaxEpochs',25,"MiniBatchSize",50,'ValidationFrequency',5,'ValidationData',roadTest_auds);
[roadnet, info] = trainNetwork(roadTrain_auds,layers,options);
roadpreds = classify(roadnet, roadTest_auds);
roadact = roadTest.Labels;
numCorrect = nnz(roadpreds == roadact);
accuracy = 100 * numCorrect / numel(roadTest.Labels)
댓글 수: 0
Joss Knight 2022년 4월 2일
The difference here is not your OS but your GPU. You have a newer GPU on your Windows 10 machine. Probably it is an Ampere GPU which is not supported for Deep Learning in R2019b (see GPU Support archive documentation).
댓글 수: 2
Joss Knight 2022년 4월 4일
Not the machine, the GPU in the machine. Type gpuDevice on your two machines and show us the output.
Find more on Image Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!