Пример #1
0
 def training_step(self, batch, batch_idx):
     masked_kspace, mask, target, fname, _, max_value = batch
     output = self.forward(masked_kspace, mask)
     target, output = T.center_crop_to_smallest(target, output)
     ssim_loss = self.ssim_loss(output.unsqueeze(
         1), target.unsqueeze(1), data_range=max_value)
     return {'loss': ssim_loss, 'log': {'train_loss': ssim_loss.item()}}
Пример #2
0
 def validation_step(self, batch, batch_idx):
     masked_kspace, mask, target, fname, slice, max_value = batch
     output = self.forward(masked_kspace, mask)
     target, output = T.center_crop_to_smallest(target, output)
     return {
         'fname': fname,
         'slice': slice,
         'output': output.cpu().numpy(),
         'target': target.cpu().numpy(),
         'val_loss': self.ssim_loss(output.unsqueeze(1), target.unsqueeze(1), data_range=max_value),
     }