Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from nnunet.training.loss_functions.dice_loss import GDiceLossV2
# from nnunet.training.loss_functions.dice_loss import GDiceLoss
from nnunet.training.network_training.nnUNetTrainer import nnUNetTrainer
from nnunet.utilities.nd_softmax import softmax_helper
class nnUNetTrainer_GDice(nnUNetTrainer):
def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None,
unpack_data=True, deterministic=True, fp16=False):
super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage,
unpack_data, deterministic, fp16)
self.apply_nonlin = softmax_helper
self.loss = GDiceLossV2(apply_nonlin=self.apply_nonlin, smooth=1e-5)
from nnunet.training.loss_functions.dice_loss import DC_and_topk_loss
# from nnunet.training.network_training import nnUNetTrainerCE
from nnunet.training.network_training.nnUNetTrainer import nnUNetTrainer
class nnUNetTrainer_DiceTopK10(nnUNetTrainer):
def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None,
unpack_data=True, deterministic=True, fp16=False):
super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage,
unpack_data, deterministic, fp16)
k = 10
self.loss = DC_and_topk_loss({'batch_dice':self.batch_dice, 'smooth':1e-5,
'do_bg':False}, {'k':k})
from nnunet.training.loss_functions.dice_loss import ExpLog_loss
from nnunet.training.network_training.nnUNetTrainer import nnUNetTrainer
import torch
class nnUNetTrainer_ExpLog(nnUNetTrainer):
def __init__(self, plans_file, fold, output_folder=None, dataset_directory=None, batch_dice=True, stage=None,
unpack_data=True, deterministic=True, fp16=False):
super().__init__(plans_file, fold, output_folder, dataset_directory, batch_dice, stage,
unpack_data, deterministic, fp16)
self.weight = torch.cuda.FloatTensor([0.2,0.8])
self.loss = ExpLog_loss({'batch_dice': self.batch_dice, 'smooth': 1e-5, 'do_bg': False, 'square': False}, {'weight':self.weight})