DigitalSlideArchive / HistomicsDetect

A package for cell detection models using TensorFlow
Apache License 2.0
3 stars 1 forks source link

mixed precision for faster rcnn #64

Open cooperlab opened 2 years ago

cooperlab commented 2 years ago

Update Faster R-CNN constituent networks and example to support mixed precision.

Each model output that feeds a loss needs to output an fp32 float. This can be accomplished by adding a linear activation with float32 type without impacting the network:

output = layers.Activation('linear', dtype='float32', name='predictions')(input)

cooperlab commented 2 years ago

Attempted this today and it was not trivial since Faster R-CNN is composed of many submodels. It required many casting operations in RoiAlign and train_step. The result was slightly slower.

Leaving this issue up in case Keras changes, or to look at performing mixed precision for the backbone only.