pykao / BraTS2018-tumor-segmentation

We provide DeepMedic and 3D UNet in pytorch for brain tumore segmentation. We also integrate location information with DeepMedic and 3D UNet by adding additional brain parcellation with original MR images.
https://www.researchgate.net/publication/326549702_Brain_Tumor_Segmentation_and_Tractographic_Feature_Extraction_from_Structural_MR_Images_for_Overall_Survival_Prediction?_sg=Omb1yK0vXPLUJ0Xx70tsfv1nTplmWLNvrZExSDIVnyVDNm3CLLGwEgUB7qjJ-MrwC6VqUvoNt-kPdQ.2
Other
106 stars 23 forks source link

Can you explain the weighting strategy in function 'hard_cross_entropy'? #1

Closed joe1chief closed 5 years ago

joe1chief commented 5 years ago
def hard_cross_entropy(output, target, alpha=3.0):
    mtx = F.cross_entropy(output, target, reduce=False)

    bg = (target == 0)    # background

    neg = mtx[bg]
    pos = mtx[1-bg]

    Np, Nn = pos.numel(), neg.numel()

    pos = pos.sum()

    k = min(Np*alpha, Nn)
    if k > 0:
        neg, _ = torch.topk(neg, int(k))
        neg = neg.sum()
    else:
        neg = 0.0

    loss = (pos + neg)/ (Np + k)

    return loss
pykao commented 5 years ago

Please refer to our paper for more details.