首页 > 解决方案 > 无法使用 DAGNetwork 类型的值作为 Matlab 中的索引

问题描述

我已经在 MATLAB 中构建了 UNET 模型,训练被中断,现在我正在尝试从最后一个检查点恢复/继续训练(在训练期间保存),但我得到了错误

" 无法使用 DAGNetwork 类型的值作为索引。

错误(第 31 行)训练 = trainNetwork(pximds,lgraph(net),options); "

这是我的代码,有人可以告诉我为什么会出现此错误。

1- clear all
2- close all
3- load('net_checkpoint__226644__2021_07_08__16_18_25.mat','net') 

4-    matlabpath = 'E:\My project';
5- data = fullfile(matlabpath,'ImageDatasetforPixelLabelDataSeries6-     
6-   21');
7-  data1 = fullfile(matlabpath,'PixelLabelDataSeries6-21');
8-  imds = imageDatastore(data,'IncludeSubfolders',true,
9-  'LabelSource','foldernames'); 
10-  classes = ["CatheterMarkerVessel" "Background"];
11-  pixelLabelIDs = [0 1];
12-  pxds = pixelLabelDatastore(data1, classes ,pixelLabelIDs);
13-  trainingdata = pixelLabelImageSource(imds,pxds);
14-  tbl = countEachLabel(trainingdata);

15-  imageSize = [1024 1024 1];
16-  numClasses = numel(classes);

17-  lgraph = unetLayers(imageSize,numClasses,'EncoderDepth',5); 
 
18-  %% Data Augmentation
19-  augmenter = imageDataAugmenter('RandXReflection',true,
20-  'RandYReflection',true);
21-   pximds = pixelLabelImageDatastore(imds,pxds,'DataAugmentation', 
22-   augmenter);
 
23-  %% Training
24-  options = trainingOptions('sgdm', ...
25-  'InitialLearnRate',0.0001, ...
26-  'Momentum',0.99, ...
27-  'MiniBatchSize',1, ... 
28-  'MaxEpochs',300, ...
29-  'Plots','training-progress', ...
30-  'CheckpointPath','E:\My Project'); 


31-  training = trainNetwork(pximds,lgraph(net),options); 

标签: matlabimage-segmentationunity3d-unet

解决方案


推荐阅读