Beispiel #1
0
 def test_compute_loss_no_scaling(self):
     exam = torch.Tensor([4.0]).repeat(2, 20, 5)
     exam2 = torch.Tensor([1.0]).repeat(2, 20, 5)
     exam11 = torch.Tensor([4.0]).repeat(2, 20)
     exam1 = torch.Tensor([1.0]).repeat(2, 20)
     d = DilateLoss()
     compute_loss(exam11, exam1, torch.rand(1, 20), d, None)
     # compute_loss(exam, exam2, torch.rand(2, 20), DilateLoss(), None)
     result = compute_loss(exam, exam2, torch.rand(2, 20), torch.nn.MSELoss(), None)
     self.assertEqual(float(result), 9.0)
Beispiel #2
0
 def test_compute_loss(self):
     crit = self.model.crit[0]
     loss = compute_loss(torch.ones(2, 20), torch.zeros(2, 20), torch.rand(3, 20, 1), crit, None, None)
     self.assertEqual(loss.item(), 1.0)