Error using trainNetwork for image classification

17 ビュー (過去 30 日間)
Sibi Isac
Sibi Isac 2018 年 1 月 5 日
コメント済み: Joss Knight 2018 年 1 月 9 日
I have following error from a classification.
Error using parallel.gpu.CUDADevice.hBuild An unexpected error occurred trying to retrieve CUDA device properties. The CUDA error was: CUDA_ERROR_UNKNOWN
Error in parallel.gpu.GPUDevice.getDevice (line 76) d = parallel.gpu.CUDADevice.hBuild( idx );
Error in parallel.gpu.GPUDevice.isAvailable (line 146) device = parallel.gpu.GPUDevice.getDevice( index );
Error in nnet.internal.cnn.util.isGPUCompatible (line 9) if(iCanUsePCT() && parallel.gpu.GPUDevice.isAvailable())
Error in nnet.internal.cnn.util.GPUShouldBeUsed (line 17) tf = nnet.internal.cnn.util.isGPUCompatible();
Error in trainNetwork>iSetupExecutionEnvironment (line 357) GPUShouldBeUsed = nnet.internal.cnn.util.GPUShouldBeUsed( ...
Error in trainNetwork (line 77) executionSettings = iSetupExecutionEnvironment( opts );
Error in imageClassification (line 34) myNet = trainNetwork(trainingImages, layers, opts); Here is the code i was trying, I couldn't figure out the reason behind the error.
clear;
close all;
clc;
% Import Training Data
trainFolder = 'Train';
testFolder = 'C:\Users\user\Google Drive\Sibi\Project\Data\test';
trainingImages = imageDatastore(trainFolder,'IncludeSubfolders',true,'FileExtensions',...
{'.jpg','.tif'} ,'LabelSource','foldernames');
testImages = imageDatastore(testFolder,'FileExtensions',{'.jpg','.tif'});
% Prepare Training Sets
% minSetCount = min([trainingImages.Count]);
% trainingSets = partition(imageSets, minSetCount, 'randomize');
% [trainingImages, testImages] = splitEachLabel(images, 0.8, 'randomize');
net = alexnet;
layers = net.Layers;
layers(23) = fullyConnectedLayer(10); % change this based on # of classes
layers(25) = classificationLayer;
miniBatchSize = 64;
numIterationsPerEpoch = floor(numel(trainingImages.Labels)/miniBatchSize);
% functions = { ...
% @plotTrainingAccuracy, ...
% @(info) stopTrainingAtThreshold(info,95)};
opts = trainingOptions('sgdm',...
'verbose',true,...
'verboseFrequency', 1,...
'InitialLearnRate', 0.001,...
'OutputFcn',@plotTrainingAccuracy);
trainingImages.ReadFcn = @readImageFunction;
myNet = trainNetwork(trainingImages, layers, opts);
print -djpeg 'TrainingProgress.jpg';
testImages.ReadFcn = @readImageFunction;
save myNet myNet;
matobj = matfile('myNet.mat');%load the pre-trained net
predictedLabels = classify(matobj.myNet, testImages);
accuracy = mean(predictedLabels == testImages.Labels);
save accuracy accuracy;
function plotTrainingAccuracy(info)
persistent plotObj
if info.State == "start"
plotObj = animatedline;
xlabel("Iteration")
ylabel("Training Accuracy")
elseif info.State == "iteration"
addpoints(plotObj,info.Iteration,info.TrainingAccuracy)
drawnow limitrate nocallbacks
end
end
I am using 2016a version of Matlab, can anyone help me sort out this problem?
>>
  3 件のコメント
Sibi Isac
Sibi Isac 2018 年 1 月 5 日
can i run this on the cpu?
Joss Knight
Joss Knight 2018 年 1 月 9 日
Yes, just add 'ExecutionEnvironment', 'cpu' to the trainingOptions.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by