Invalid network of Object Detector

1 view (last 30 days)
Beatriz Martins
Beatriz Martins on 11 Jan 2020
Answered: Ajay Gajulapally on 2 Jan 2023
I am using Alexnet for transfer learning.
I used trainFasterRCNNObjectDetector function to train 25000 images and obtained a detector. Now I want to use the layers of this detector to train more 25000 different images. However, during training the function added new layers and this detector (https://drive.google.com/file/d/1uJmNmPWkgoujM6pONVP-I61EuA_jKtK4/view?usp=sharing) returns a Network with 35 layers (insted of 25 like alexnet).
Therefore, when I try to run again the trainFasterRCNNObjectDetector with layers of my detector I get the following error:
Error using trainFasterRCNNObjectDetector (line 333)
Invalid networkInvalid network.
Error in train_detector (line 34)
detector = trainFasterRCNNObjectDetector(trainingData, layers, options)
Caused by:
Network: Too many output layers. The network must have one output layer.
Detected output layers:
layer 'rpnBoxDeltas'
layer 'rpnClassification'
layer 'classoutput'
layer 'boxDeltas'
Layer 'regionProposal': Missing input. Each layer input must be connected to the output of another layer.
Detected missing inputs:
input 'boxDeltas'
Layer 'roiPooling': Missing input. Each layer input must be connected to the output of another layer.
Detected missing inputs:
input 'roi'
Layer 'rpnClassification': Missing softmax layer. A classification layer must be preceded by a softmax layer.
Does anyone know how to solve this problem?

Answers (1)

Ajay Gajulapally
Ajay Gajulapally on 2 Jan 2023
A solution to train your detector without adding more number of layers when training second time can be by using "CheckpointPath" in trainingOptions. You can use CheckpointPath to save the progress of layers of detector after every "CheckpointFrequency" of "CheckpointFrequencyUnit" (these two are also in trainingOptions)
CheckpointPath can be a location of a folder where you want to save the progress of trained detector.
CheckpointFrequencyUnit can be "epoch" or "iteration"
CheckpointFrequency can be a number, which tells you after how many times again you want to save the progress of trained detector.
In your case if number of epochs are 10 (say) -> then set CheckpointFrequencyUnit to 'epoch' and CheckpointFrequency to 10.
1. Then Load the detector as
load('checkpoint_file_name.mat','net');
2. Resume Training with this detector network as layer graph and the new data you have just as you did the training for the first time.

Categories

Find more on Image Data Workflows 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!