def loss(outputs, labels): f = torch.nn.BCELoss(reduction='none') floss = f(outputs,labels) dloss = bratsUtils.bratsDiceLoss(outputs, labels, nonSquared=True) num_voxels = np.prod(floss.shape) res1, _ = torch.topk(floss.view((-1, )), int(num_voxels * topK), sorted=False) num_voxels = np.prod(dloss.shape) res2, _ = torch.topk(dloss.view((-1, )), int(num_voxels * topK), sorted=False)#for batch_size >1 if len(res2)==0: return floss.mean()+dloss.mean()+res1.mean() else: return floss.mean()+dloss.mean()+res1.mean()+res2.mean()
def loss(outputs, labels): f = torch.nn.BCELoss(reduction='none') floss = f(outputs, labels) filter = torch.zeros(2, 2, 3, 3, 3).cuda() filter[:, :, 0, 1, 1] = 1 filter[:, :, 1, 1, 0] = 1 filter[:, :, 0, 1, 1] = 1 filter[:, :, 2, 1, 1] = 1 filter[:, :, 1, 1, 2] = 1 filter[:, :, 2, 1, 1] = 1 filter[:, :, 1, 1, 1] = -6 mask = F.conv3d(labels, filter, padding=1) floss = torch.mean(floss) + 2 * torch.mean(floss[mask != 0]) return bratsUtils.bratsDiceLoss(outputs, labels, nonSquared=True).mean() + floss
def loss(outputs, labels): return bratsUtils.bratsDiceLoss(outputs, labels, nonSquared=True)
def loss(outputs, labels): f1 = torch.nn.BCELoss(reduction='mean') f2 = torch.nn.MSELoss(reduction='mean') return bratsUtils.bratsDiceLoss(outputs, labels, nonSquared=True) + f1( outputs, labels) + f2(outputs, labels)
def loss(outputs, labels): f = torch.nn.BCELoss(reduction='mean') return bratsUtils.bratsDiceLoss( outputs, labels, nonSquared=True).mean() + 10 * f(outputs, labels)