flag_simu=opt['loader']) trainLoader_ICH = data.DataLoader(dataLoader_train_ICH, batch_size=batch_size, shuffle=True) epoch = 0 gen_iterations = 1 display_iters = 5 loss1_sum, loss2_sum = 0, 0 Validation_loss = [] loss_L1 = lossL1() while epoch < niter: epoch += 1 # training phase unet3d.train() for idx, (rdf_inputs, rdfs, masks, weights, wGs, D) in enumerate(trainLoader_ICH): # training of unet3d rdf_inputs0 = (rdf_inputs.to(device0, dtype=torch.float) + trans) * scale rdfs0 = (rdfs.to(device0, dtype=torch.float) + trans) * scale masks0 = masks.to(device0, dtype=torch.float) weights0 = weights.to(device0, dtype=torch.float) wGs0 = wGs.to(device0, dtype=torch.float) if epoch == 1: QSM = unet3d(rdf_inputs0)[:, 0, ...] QSM = np.squeeze(np.asarray(QSM.cpu().detach())) adict = {} adict['QSM'] = QSM
flag_RDF_input=1) trainLoader_ICH = data.DataLoader(dataLoader_train_ICH, batch_size=batch_size, shuffle=True) epoch = 0 gen_iterations = 1 display_iters = 5 loss1_sum, loss2_sum = 0, 0 Validation_loss = [] loss_L1 = lossL1() while epoch < niter: epoch += 1 # training phase unet3d.train(), resnet.train() for idx, (rdf_inputs, rdfs, masks, weights, wGs, D) in enumerate(trainLoader_ICH): # training of unet3d rdf_inputs0 = rdf_inputs.to(device0, dtype=torch.float) rdfs0 = rdfs.to(device0, dtype=torch.float) masks0 = masks.to(device0, dtype=torch.float) weights0 = weights.to(device0, dtype=torch.float) wGs0 = wGs.to(device0, dtype=torch.float) loss_fidelity = BayesianQSM_train(model=unet3d, input_RDFs=rdf_inputs0, in_loss_RDFs=rdfs0, QSMs=0, Masks=masks0, fidelity_Ws=weights0,
use_deconv=1, use_deconv2=1, renorm=0, flag_r_train=0, flag_UTFI=1) model.to(device) # optimizer optimizer = optim.Adam(model.parameters(), lr=lr, betas=(0.5, 0.999)) Validation_loss = [] loss_total_list = [] while epoch < niter: # training phase model.train() for idx, (ifreqs, masks, data_weights, wGs) in enumerate(trainLoader): ifreqs = ifreqs.to(device, dtype=torch.float) masks = masks.to(device, dtype=torch.float) data_weights = data_weights.to(device, dtype=torch.float) wGs = wGs.to(device, dtype=torch.float) loss_PDF, loss_fidelity, loss_tv = utfi_train(model, optimizer, ifreqs, masks, data_weights, wGs, D, D_smv, lambda_pdf,