Retraining Alexnet - works on windows 7 not on windows 10?

2 views (last 30 days)
James Silk
James Silk on 1 Apr 2022
Commented: Joss Knight on 4 Apr 2022
Hi All,
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)

Answers (1)

Joss Knight
Joss Knight on 2 Apr 2022
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 Comments
Joss Knight
Joss Knight on 4 Apr 2022
Not the machine, the GPU in the machine. Type gpuDevice on your two machines and show us the output.

Sign in to comment.

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by