models icon indicating copy to clipboard operation
models copied to clipboard

Can't configure Faster R-CNN with Inception Resnet v2 by modify first_stage_features_stride size

Open chenyuZha opened this issue 9 years ago • 13 comments

Describe the problem

In the configure file faster_rcnn_inception_resnet_v2_atrous_pets.config, I would like to modify the first_stage_features_stride in the

feature_extractor { type: 'faster_rcnn_inception_resnet_v2' first_stage_features_stride: 8 } from 8 to 4, but I got the error: ValueError: first_stage_features_stride must be 8 or 16.

In general, with a smaller stride size gives a better accuracy. If I would like to improve the accuracy of model, does it exist another way?

chenyuZha avatar Aug 10 '17 12:08 chenyuZha

It means how much you will go in depth in-terms of the convolutional to extract features . (for box prediction , class prediction and objectiveness score prediction) .

Roughly you can get the feature stride from = Height of the input / Height of the convolution layer map .

Normally you can change this according to the architecture . But there's this exception where faster rcnn meta-architecture will only allow you to extract features from layers only of stride 8 and 16 .

Read this script in TF-OD API

shamanez avatar Aug 11 '17 11:08 shamanez

@shamanez Thanks for your information. And is it true that with a smaller stride size will return a better accuracy(prediction)? Does it exist another way to increase accuracy of model ? Like modify the steps when learning rate decays. Because I saw this in the configuration file: learning_rate: { manual_step_learning_rate { initial_learning_rate: 0.0003 schedule { step: 0 learning_rate: .0003 } schedule { step: 900000 learning_rate: .00003 } schedule { step: 1200000 learning_rate: .000003 } The learning_rate will decrease when reach step:900000, so maybe I should modify this much more smaller (like 50000 for example) .

chenyuZha avatar Aug 11 '17 13:08 chenyuZha

@chenyuZha Well it's different . Small stride means you have a larger receptive field . The thing is normally lower layers extract much more local features , like edges , pixel differences etc . But higher layers extract more global features like shapes . So if you need some dense prediction like in semantic segmentation you might want to use lower stride . That is what happening in FCN network . SO for object detection it might not as effective as much . Not sure though ! But logically it's above case .

I am aslo trying to increase the accuracy of SSD with mobile net . Yeah learning rate will play a huge thing . But the thing is here we are working with already trained model . They decay learning rate to keep the model near a global minima . If you lower in frequently it might take more time to converge . Did you tried to work with batch size ?

What is the optimization algorithm they are using , is it SGD with momentum ?

shamanez avatar Aug 14 '17 05:08 shamanez

@shamanez I didn't change the batch_size for fasterRcnn model, by default the batch_size=1 in my case and in ssd model is 24. To increase accuracy , batch_size doesn't help because it'll just control the speed of training, like if you have a bigger batch_size, your training process will be longer in each step, since the algorithm decent gradient will try to minimize the cross entropy of more samples.

And I agree that learning rate will still have some influences with accuracy even though we are working with a pre-trained model. I have decreased the step of decay learning rate ( 900000 to 50000) and when I compared the output images of bounding boxes , the one with a smaller step of decay learning rate detected more objects. Based on the configuration file, the optimization algorithm is SGD with momentum.(May be you should choose use_moving_average: True to switch on?

momentum_optimizer: { learning_rate: { manual_step_learning_rate { initial_learning_rate: 0.0003 schedule { step: 0 learning_rate: .0003 } schedule { step: 50000 learning_rate: .00003 } schedule { step: 90000 learning_rate: .000003 } } } momentum_optimizer_value: 0.9 } use_moving_average: false }

chenyuZha avatar Aug 14 '17 09:08 chenyuZha

@chenyuZha
There can be an influence on the batch-size . Because if we use online training the converging is more zig-zag. But when we use SGD it's good . Any way larger the batch size it will take more time to converge. Here Batch size 1 means each worker will take 1 image at a time , making 5 if there are 5 workers ?

Did you tried ssd with mobile net ? Um getting some false positves . So I am thinking of number of negative samples parameter .

use_moving_average: True By this do we calculate nestrov momentum ?

shamanez avatar Aug 14 '17 09:08 shamanez

@chenyuZha I changed the learning_rate for faster_Rcnn model, and it just works on some datasets, not all. How much your model's accuracy? I am working on increase accuracy too, but I do not find the useful method now.

FiveMaster avatar Aug 17 '17 10:08 FiveMaster

@FiveMaster Did you play around dropout ?

shamanez avatar Aug 17 '17 10:08 shamanez

@shamanez no,use_dropout: false, Did I need to set it to true?

FiveMaster avatar Aug 18 '17 01:08 FiveMaster

yeah. If your training accuracy is high but not validation use it

shamanez avatar Aug 18 '17 10:08 shamanez

@FiveMaster I didn't look at accuracy , I just check the image results to see if if detects more objects. basically, the output images will show the bounding boxes with threshold >0.5.

chenyuZha avatar Aug 21 '17 10:08 chenyuZha

@shamanez I checked the results with switch on 'use_move_average=True'. To be honest, I didn't see a very great difference. I haven't tried the ssd mobile_net yet, since this model gives a lower accuracy than faster_rcnn.

chenyuZha avatar Aug 21 '17 10:08 chenyuZha

@chenyuZha Now the model thatI am training has a great accuracy, maybe we can discuss the problems of your model and I hope I can help you. Maybe you can describe your problem and your model in more detail. Look at your name, are you Chinese?

FiveMaster avatar Aug 23 '17 08:08 FiveMaster

I'm going to close this, for book-keeping purposes, since this is not an issue per se, and I think it would be nice to have this on stackoverflow.

Feel free to continue corresponding on this thread, even closed, if you wish.

drpngx avatar Sep 07 '17 01:09 drpngx