필터 지우기
필터 지우기

I need help on this Deep Network Quantizer code

조회 수: 2 (최근 30일)
ikeuwanuakwa
ikeuwanuakwa 2020년 10월 19일
net = inceptionresnetv2();
quantobj = dlquantizer(net,'ExecutionEnvironment','GPU');
imds = imageDatastore('data', ...
'IncludeSubfolders',true, ...
'LabelSource','foldernames');
[calData, valData] = splitEachLabel(imds, 0.6, 'randomized');
aug_calData = augmentedImageDatastore([299 299], calData);
aug_valData = augmentedImageDatastore([299 299], valData);
quantObj = dlquantizer(net);
function accuracy = hComputeModelAccuracy(predictionScores, net, dataStore)
%% Computes model-level accuracy statistics
% Load ground truth
tmp = readall(dataStore);
groundTruth = tmp.response;
% Compare with predicted label with actual ground truth
predictionError = {};
for idx=1:numel(groundTruth)
[~, idy] = max(predictionScores(idx,:));
yActual = net.Layers(end).Classes(idy);
predictionError{end+1} = (yActual == groundTruth(idx)); %#ok
end
% Sum all prediction errors.
predictionError = [predictionError{:}];
accuracy = sum(predictionError)/numel(predictionError);
end
quantOpts = dlquantizationOptions('MetricFcn', ...
{@(x)hComputeModelAccuracy(x, net, aug_valData)});
calResults = calibrate(quantObj, aug_calData)
valResults = validate(quantObj, aug_valData, quantOpts)
valResults.MetricResults.Result
Error
Function definitions in a script must appear at the end of the file.
Move all statements after the "hComputeModelAccuracy" function definition to before the first local function
definition.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Quantization, Projection, and Pruning에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by