Effacer les filtres
Effacer les filtres

Unable to use a value of type DAGNetwork as an index.

6 vues (au cours des 30 derniers jours)
Adnan Iltaf
Adnan Iltaf le 14 Juil 2021
I have build the UNET model, the training was interrupted,Now I am trying to resume the training from the last checkpoint, but i got the Error "Unable to use a value of type DAGNetwork as an index."
Here is my code, can someone tell me why i got this error.
clear all
close all
load('net_checkpoint__226644__2021_07_08__16_18_25.mat','net')
matlabpath = 'E:\My project';
data = fullfile(matlabpath,'ImageDatasetforPixelLabelDataSeries6-21');
data1 = fullfile(matlabpath,'PixelLabelDataSeries6-21');
imds = imageDatastore(data,'IncludeSubfolders',true,'LabelSource','foldernames');
classes = ["CatheterMarkerVessel" "Background"];
pixelLabelIDs = [0 1];
pxds = pixelLabelDatastore(data1, classes ,pixelLabelIDs);
trainingdata = pixelLabelImageSource(imds,pxds);
tbl = countEachLabel(trainingdata);
imageSize = [1024 1024 1];
numClasses = numel(classes);
lgraph = unetLayers(imageSize,numClasses,'EncoderDepth',5);
%% Data Augmentation
augmenter = imageDataAugmenter('RandXReflection',true,'RandYReflection',true);
pximds = pixelLabelImageDatastore(imds,pxds,'DataAugmentation', augmenter);
%% Training
options = trainingOptions('sgdm', ...
'InitialLearnRate',0.0001, ...
'Momentum',0.99, ...
'MiniBatchSize',1, ...
'MaxEpochs',300, ...
'Plots','training-progress', ...
'CheckpointPath','E:\My Project');
training = trainNetwork(pximds,lgraph(net),options);

Réponses (1)

Yomna Genina
Yomna Genina le 19 Août 2021
There is no need to create a new layer graph as you already saved the last checkpoint network in the net variable which could be used directly to resume training.
Instead of the last line of code, you could do the following:
training = trainNetwork(pximds,layerGraph(net),options); % convert DAGNetwork to layer graph and resume training

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by