RCNN has no public property 'NumObservations'

2 views (last 30 days)
Hello, I'm a relative newbie to MATLAB and neural networks, and I'm looking at disease spread and analysis in crop fields. I wanted to make an RCNN to help with this. I have some skeleton code, but I'm getting errors I don't understand and don't have the skill to debug.
Here is the code:
load 'D:\Documents\MATLAB\bridgeLabels.mat', 'gTruth';
%these are the labels I made in the image labeler app
trainingData = objectDetectorTrainingData(gTruth);
%this apparently makes the training data for me
classes = {'clubroot', 'healthy'};
outputs = 1+numel(classes);
layers = [imageInputLayer([2160 3840 3])
convolution2dLayer([5 5],10)
reluLayer()
fullyConnectedLayer(options)
softmaxLayer()
classificationLayer()];
%I understand what all these things do, kind of.
%I just copied this code from the demonstration in the reference
%I'm getting some error with the classification layer I don't know how to fix
options = trainingOptions('sgdm',...
'LearnRateSchedule','piecewise',...
'LearnRateDropFactor',0.2,...
'LearnRateDropPeriod',5,...
'MaxEpochs',20,...
'MiniBatchSize',64,...
'Plots','training-progress');
%again, most of this makes sense to me
detector = trainRCNNObjectDetector(trainingData, layers, options);
%ok so now the network is made apparently
image = imread('D:\Documents\MATLAB\clubroot_shots\lcbo1.png');
%this is my testing image
wid = 10;
rois = zeros(1, (image.width/wid)*(image.height/wid));
for i=1:image.width/wid
for j=1:image.height/wid
rois(i+j*width) = [1+(i-1)*wid, 1+(j-1)*wid, wid, wid];
end
end
%I believe this code will split up the image into 10x10 regions of interest.
%I wrote this block myself.
classifyRegions(detector, image, rois)
%and here the regions get classified. Semicolon off because i want to see what happens
When I run this code, I get the following errors:
*******************************************************************
Training an R-CNN Object Detector for the following object classes:
* clubroot
* healthy
Step 1 of 3: Extracting region proposals from 2 training images...done.
Step 2 of 3: Training a neural network to classify objects in training data...
Error using trainNetwork (line 140)
No public property 'NumObservations' for class 'RegionReader'.
Error in rcnnObjectDetector.train (line 222)
detector.Network = trainNetwork(dispatcher, layers, opts);
Error in trainRCNNObjectDetector (line 197)
detector = rcnnObjectDetector.train(trainingData, layers, options, params);
Error in imagenn (line 23)
detector = trainRCNNObjectDetector(trainingData, layers, options);
Error in run (line 91)
evalin('caller', strcat(script, ';'));
Caused by:
No public property 'NumObservations' for class 'RegionReader'.
As you can see, it seems to get through step 1 ok, but at step two it trips up. I'm a little out of my depth here, so I don't know what NumObservations or RegionReader are, so any help would be appreciated.

Answers (1)

Steven Lord
Steven Lord on 23 Apr 2018
Which release are you using?
What is "the reference" to which you refer in the comment:
%I just copied this code from the demonstration in the reference
If you're using the online documentation (which is for the current release, which right now is release R2018a) as your reference and you're using an older release that reference example may use functionality not available in the release you're using.
  1 Comment
Griffon Thomas
Griffon Thomas on 23 Apr 2018
Edited: Griffon Thomas on 23 Apr 2018
Hm, this could be it. It seems right now I'm running the R2017b version. However, I used the in-app reference rather than the online one, and that code snippet was taken from the 'Layer' page. Do you know what I can do then?

Sign in to comment.

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!