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

3 次查看(过去 30 天)
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);

回答(1 个)

Yomna Genina
Yomna Genina 2021-8-19
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

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by