DeepRegNet / DeepReg

Medical image registration using deep learning
Apache License 2.0
560 stars 76 forks source link

Define loss using LossFunctionWrapper #737

Closed mathpluscode closed 3 years ago

mathpluscode commented 3 years ago

Subject of the issue

The implementations of loss and metric are different, i.e.

MSE loss https://github.com/tensorflow/tensorflow/blob/v2.4.1/tensorflow/python/keras/losses.py#L267-L322 MSE metric https://github.com/tensorflow/tensorflow/blob/v2.4.1/tensorflow/python/keras/metrics.py#L2378-L2410 They are different classes calling the same functions.

So we should refactor existing losses so that we can have the corresponding metrics without duplicated code

The concern is that: if we add a metric from a loss object, will that loss be automatically logged?

mathpluscode commented 3 years ago

Refactoring all loss functions is a lot of work. As for now we only consider dice score as a metric. I will close this issue and open a new one dedicate for dice and SSD.

mathpluscode commented 3 years ago

Actually, i will do it in https://github.com/DeepRegNet/DeepReg/issues/735.