How can I test the network I've trained?

28 ビュー (過去 30 日間)
Ferhat Kangal
Ferhat Kangal 2022 年 12 月 29 日
回答済み: Christopher McCausland 2022 年 12 月 29 日
Hello everybody, I have trained a CNN model which is Resnet50 and now I want to test it with different dataset and get accuracy. Anyone has any idea how can I do that? I have created a imageDataStore called imdsTest which has 5 classes and thousands of images in the classes.

回答 (1 件)

Christopher McCausland
Christopher McCausland 2022 年 12 月 29 日
Hi Ferhat,
If you have trained the model it will save to your workspace as a fancy variable 'model'. You can use this to then test with images it hasn't seen before.
% Lets generate a network -- Yours may look slightly diffrent, thats okay
miniBatchSize = 128;
validationFrequency = floor(numel(YTrain)/miniBatchSize);
options = trainingOptions('sgdm', ...
'MiniBatchSize',miniBatchSize, ...
'MaxEpochs',30, ...
'InitialLearnRate',1e-3, ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropFactor',0.1, ...
'LearnRateDropPeriod',20, ...
'Shuffle','every-epoch', ...
'ValidationData',{XValidation,YValidation}, ...
'ValidationFrequency',validationFrequency, ...
'Plots','training-progress', ...
'Verbose',false);
% Lets train it;
net = trainNetwork(XTrain,YTrain,layers,options);
% Finally lets test our network;
YPredicted = predict(net,imdsTest);
Here is a further example (that I have also borrowed from as I don't have a network to hand).
Kind regards,
Christopher

カテゴリ

Help Center および File ExchangeParallel and Cloud についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by