Filter löschen
Filter löschen

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

6 Ansichten (letzte 30 Tage)
Adnan Iltaf
Adnan Iltaf am 14 Jul. 2021
Beantwortet: Yomna Genina am 19 Aug. 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);

Antworten (1)

Yomna Genina
Yomna Genina am 19 Aug. 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

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by