错误:内存不足

1视图(30天)
莫妮卡Zikmundova
莫妮卡Zikmundova 2021年6月6日
回答: Srivardhan Gadila 2021年6月9日
你好,
我写信是更快r-cnn网络脚本搜索陨石坑。当您运行这个脚本时,matlab生成一个内存不足错误消息。有人请告诉我如何解决这个问题?
我的matlab代码:
清晰的所有
关闭所有
clc
格式长g
data =负载(“matlab_V21_ROI_11_3_2021.mat”)
gTruth = data.gTruth;
gTruth.DataSource
gTruth.LabelDefinitions;
replaceimds = imageDatastore (“C: \莫妮卡\ vse \ kratery”)
replaceDataSource = groundTruthDataSource (replaceimds)
gTruth.DataSource = replaceDataSource
% objectdetector
trainingDataTable = objectDetectorTrainingData (gTruth);
% (imd,建筑物)= objectDetectorTrainingData (gTruth);
% cd =结合(imd,建筑物)
%读(cds)
%数= countEachLabel (cds)
filenamesImages = trainingDataTable.imageFilename
tblBoxes = trainingDataTable (:,“稀有”)
imd = imageDatastore (filenamesImages,“LabelSource”,“foldernames”)
建筑物= boxLabelDatastore (tblBoxes)
cd =结合(imd,建筑物)
% prevod na RGB
numberofImages =长度(imds.Files)
k = 1: numberofImages
inputFileName = imds.Files {k};
流(“检查% s \ n”,inputFileName);
grayImage = imread (inputFileName);
(行、列,numberofColorChannels) = (grayImage)大小;
如果numberofColorChannels = = 1
rgbImage =猫(3 grayImage grayImage grayImage);
imshow (rgbImage);
其他的
imshow (rgbImage);
结束
轴(“上”,“图像”);
%暂停(0.1);
结束
%锚箱我
网络= resnet50;% squeezenet;% resnet50
inputImageSize = (224 224 3);% network.Layers .InputSize (1);
%形象增压器
imageAugmenter = imageDataAugmenter (
“RandRotation”90年[0],
“RandScale”(0.5 - 1));
augmentedImdsTrain = augmentedImageDatastore (inputImageSize, imd,“DataAugmentation”imageAugmenter,“OutputSizeMode”,“randcrop”);% ořiznuti z nahodneho umistěni ve vstupnim obrazku
% preprocessedTrainingData =变换(cd, @(数据)preprocessData(数据、inputImageSize));
numClasses = 1;
featureLayer =“activation_40_relu”;% ' fire5-concat ' % ' activation_40_relu ';
%估计锚箱
numAnchors = 3
[anchorBoxes, meanIoU] = estimateAnchorBoxes (cd, numAnchors);
anchorBoxes
meanIoU
maxNumAnchors = 3;
meanIoU = 0 ([maxNumAnchors, 1]);
anchorBoxes =细胞(maxNumAnchors, 1);
k = 1: maxNumAnchors
%估计锚和意味着借据。
[anchorBoxes {k}, meanIoU (k)] = estimateAnchorBoxes (cd, k);
结束
阴谋(1:maxNumAnchors meanIoU,“o”)
ylabel (“意思是借据”)
包含(“锚”)
标题(“许多锚与意思借据”)
%锚箱——pokracovani
anchorBoxes = [72、70;99年,96年;53岁的51];
lgraph = fasterRCNNLayers (inputImageSize numClasses anchorBoxes,
网络,featureLayer);
analyzeNetwork (lgraph);
选择= trainingOptions (“个”,
“MiniBatchSize”, 1
“InitialLearnRate”1 e - 3,
“MaxEpochs”5);
探测器= trainFasterRCNNObjectDetector (cd、lgraph选项,
“NegativeOverlapRange”,0.3 [0],
“PositiveOverlapRange”(0.6 - 1));

答案(1)

Srivardhan Gadila
Srivardhan Gadila 2021年6月9日
如果你的网络是被训练在GPU那么似乎GPU内存是不够的,你可以设置 “ExecutionEnvironment” “cpu” trainingOptions 并尝试训练网络。或者你也可以检查 提示 部分的 trainFasterRCNNObjectDetector 可能的解决方法提出了“内存不足”的问题。
如果上面的建议然后你可以联系工作 Mathworks支金宝app持

标签

社区寻宝

找到宝藏在MATLAB中央,发现社区如何帮助你!

开始狩猎!