Changing num_layers won't help you in this case.
SSD has several detection branches - each branch derived from different feature map resolution
For example - for mobilenet_v1_ssd found in TF OD API there are 6 branches.
branch 0 - 19x19
branch 1 - 10x10
branch 2 - 5x5
branch 3 - 3x3
branch 4 - 2x2
branch 5 - 1x1
So the argument - num_layers will actually change the number of branches but not the number of anchors per pixel.
In case you want to have only one anchor box per pixel you will have to change the several things (read until the end :) ):
- Aspect ratios - By changing the number of aspect ratios you change the number of anchors per layer. so:
anchor_generator {
ssd_anchor_generator {
num_layers: 6
min_scale: 0.2
max_scale: 0.95
aspect_ratios: 1.0
aspect_ratios: 2.0
aspect_ratios: 0.5
aspect_ratios: 3.0
aspect_ratios: 0.3333
}
}
So by removing but 1.0, for example, will leave you almost with one anchor.
2. Why almost? SSD (https://arxiv.org/abs/1512.02325), see the paper, add another anchor box with a scale of a geometric mean between current branch scale to next branch scale. So you will actually have 2 anchors per pixel for branches 1-5. In order to disable it you should change a parameter named - interpolated_scale_aspect_ratio to 0.

You can do it by adding this argument to the config file (see the protobuf of ssd anchors - https://github.com/tensorflow/models/blob/2ad3e213838f71e92af198d917ac5574c9d60294/research/object_detection/protos/ssd_anchor_generator.proto)
so under anchor_generator add:
interpolated_scale_aspect_ratio: 0
- If you followed 1 and 2, you will see that you have 1 anchor per pixel per branch but for branches 1-5. But for some reason you will have 3 anchors for the first branch... This is because the first branch is getting three anchors by default. You can disable it by using the following argument:

reduce_boxes_in_lowest_layer: false