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

1 次查看(过去 30 天)
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)

回答(1 个)

Joss Knight
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 个评论
James Silk
James Silk 2022-4-4
Thanks Joss for the answer, So it seems that it might be that the machine is newer than the version of matlab that is causing the error in the answers if I'm understanding that right? It also seems like the only solution is to have the matlab 2021a or b installed?
Thanks again for your answer.
Joss Knight
Joss Knight 2022-4-4
Not the machine, the GPU in the machine. Type gpuDevice on your two machines and show us the output.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by