alexander-pv / maskrcnn_tf2

Mask R-CNN for object detection and instance segmentation with Keras and TensorFlow V2 and ONNX and TensorRT optimization support.
Other
40 stars 11 forks source link

batch norm layers #7

Closed VeeranjaneyuluToka closed 2 years ago

VeeranjaneyuluToka commented 2 years ago

Hi,

I noticed that you set all the backbone batch norm layers to False, would you mind letting me know the reason behind it?

    # Set trainable=False to all batchnorm layers
    bn_layers = [x.name for x in model.layers if 'bn' in x.name]
    for layer_name in bn_layers:
        print(layer_name)
        model.get_layer(layer_name).trainable = False

I noticed that 'Not allowing bn' layers in training causes poor accuracy especially for EfficientNet. Wondering in case if you notice different behavior.

Thanks, Veeru.

alexander-pv commented 2 years ago

Hi, @VeeranjaneyuluToka,

For small batches matterport advice to switch off batch normalization. I did some tests only with batch size 1 and 2 because of the resource limitations and didn't notice accuracy gap. Thank you for the comment. It is a good point to research. Perhaps, batchnorm switching should be also more flexible for each subgraph.

alexander-pv commented 2 years ago

Option added: https://github.com/alexander-pv/maskrcnn_tf2/blob/7988ac0edc438dda05076acc03f2f03d179439d5/src/layers/mrcnn_layers.py#L1374