def test_loss_init(self): name = "name" shortname = "shortname" inputs = "decoder_output" targets = "decoder_output" loss = Loss(name, shortname, inputs, targets, torch.nn.NLLLoss()) self.assertEqual(loss.name, name) self.assertEqual(loss.log_name, shortname)
def test_loss_backward_WITH_NO_LOSS(self): loss = Loss("name", torch.nn.NLLLoss()) self.assertRaises(ValueError, lambda: loss.backward())
def test_loss_init_WITH_NON_LOSS(self): self.assertRaises(ValueError, lambda: Loss("name", "loss"))
def test_loss_init(self): name = "name" loss = Loss(name, torch.nn.NLLLoss()) self.assertEqual(loss.name, name)
def test_loss_init_WITH_NON_LOSS(self): self.assertRaises( ValueError, lambda: Loss("name", "shortname", "decoder_outputs", "decoder_targets", "loss"))