def train(): # args = brats2019_arguments() utils.reproducibility(args, seed) utils.make_dirs(args.save) ( training_generator, val_generator, full_volume, affine, ) = medical_loaders.generate_datasets(args) model, optimizer = medzoo.create_model(args) val_criterion = DiceLoss(classes=11, skip_index_after=args.classes) # criterion = DiceLoss(classes=3, skip_index_after=args.classes) # criterion = DiceLoss(classes=args.classes) criterion = torch.nn.CrossEntropyLoss() if args.cuda: model = model.cuda() print("Model transferred in GPU.....") trainer = train_module.Trainer( args, model, criterion, optimizer, val_criterion=val_criterion, train_data_loader=training_generator, valid_data_loader=val_generator, lr_scheduler=None, ) print("START TRAINING...") trainer.training()
def main(): args = get_arguments() utils.reproducibility(args, seed) utils.make_dirs(args.save) training_generator, val_generator, full_volume, affine = medical_loaders.generate_datasets( args, path='.././datasets') model, optimizer = medzoo.create_model(args) criterion = DiceLoss(classes=args.classes) if args.cuda: model = model.cuda() print("Model transferred in GPU.....") trainer = train.Trainer(args, model, criterion, optimizer, train_data_loader=training_generator, valid_data_loader=val_generator, lr_scheduler=None) print("START TRAINING...") trainer.training() visualize_3D_no_overlap_new(args, full_volume, affine, model, 10, args.dim)
def main(): args = get_arguments() utils.reproducibility(args, seed) utils.make_dirs(args.save) training_generator, val_generator, full_volume, affine = medical_loaders.generate_datasets(args, path='.././datasets') model, optimizer = medzoo.create_model(args) criterion = DiceLoss(classes=args.classes) if args.cuda: model = model.cuda() trainer = train.Trainer(args, model, criterion, optimizer, train_data_loader=training_generator, valid_data_loader=val_generator) trainer.training()
def main(): args = get_arguments() utils.reproducibility(args, seed) utils.make_dirs(args.save) training_generator, val_generator, full_volume, affine = medical_loaders.generate_datasets( args, path='.././datasets') model, optimizer = medzoo.create_model(args) criterion = DiceLoss( classes=args.classes ) # ,skip_index_after=2,weight=torch.tensor([0.00001,1,1,1]).cuda()) if args.cuda: model = model.cuda() print("Model transferred in GPU.....") trainer = train.Trainer(args, model, criterion, optimizer, train_data_loader=training_generator, valid_data_loader=val_generator) print("START TRAINING...") trainer.training()