In the paper "A NOVEL FOCAL TVERSKY LOSS FUNCTION WITH IMPROVED ATTENTIONU-NETFOR LESION SEGMENTATION" the author use deep supervision by outputing multiple outputmask which have different scale.

I do not understand how it can work with regards to the loss function. y_pred and y_true doesnt share the same dimension exept for the final output.

model = Model(inputs=[img_input], outputs=[out6, out7, out8, out9])

the input seems to only be the one with real resolution

enter image description here

I checked the code (https://github.com/nabsabraham/focal-tversky-unet/blob/master/newmodels.py) and I haven't see anything special that would make it works. The loss function doesn't explicitly handle it neither.


As you can see in lines 286-296 in newmodels.py the model can use two different loss functions for the four different outputs.

loss = {'pred1':lossfxn,
        'final': losses.tversky_loss}
loss_weights = {'pred1':1,
model.compile(optimizer=opt, loss=loss, loss_weights=loss_weights,

The first three outputs of the model, out6, out7, and out8 uses the loss function, lossfxn, which is given as the third argument to the attn_reg function. In isic_train.py, this happens to be the Focal Tversky Loss. For the final output of the UNet (out9) the Focal Tversky Loss is always used. The total loss for the model is then the weighted sum of the different losses for the four model outputs, which is simply equal to the sum given that all weights are set to 1 in loss_weights.

  • $\begingroup$ I have see this but I dont understand how the loss is computed since pred 1 2 & 3 doesnt have the same output dimension as the input. $\endgroup$ – Chopin Jul 28 '20 at 15:07
  • $\begingroup$ The loss is simply computed for all four outputs seperately, resulting in four loss values. These four losses are then summed to get the total loss of the model. $\endgroup$ – Oxbowerce Jul 28 '20 at 16:10
  • $\begingroup$ Yes but how. The input image (y_true) doesn’t have the same dimension as the image pred 1 (which is downscaled) $\endgroup$ – Chopin Jul 28 '20 at 16:24
  • 1
    $\begingroup$ As you can see in the image and in isic_train.py (line 75), the input consists of four multi-scale inputs. These are then used to calculate the losses for each of the four levels. $\endgroup$ – Oxbowerce Jul 28 '20 at 16:50
  • $\begingroup$ thank you very much for pointing that out, this is definitely what I was missing. In addition, didn't it is odd to use a slicing operator rather that max pooling to resample the gt image since max pooling is used to compute the downscaled input ? $\endgroup$ – Chopin Jul 29 '20 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.