Unable to use a value of type DAGNetwork as an index.
조회 수: 1 (최근 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);
댓글 수: 0
답변 (1개)
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
This example on using a checkpoint network might be useful: https://www.mathworks.com/help/deeplearning/ug/resume-training-from-a-checkpoint-network.html
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!