Fix build on Xcode 14 (#116)

* Fix build on Xcode 14

* Style fixes
This commit is contained in:
Angelos Katharopoulos
2023-12-10 06:58:52 -08:00
committed by GitHub
parent ef7b8756c0
commit 600db7d754
4 changed files with 23 additions and 13 deletions

View File

@@ -42,11 +42,11 @@ class TestNN(mlx_tests.MLXTestCase):
targets = mx.array([0.5, 0.2, 0.9, 0.0])
losses = nn.losses.l1_loss(predictions, targets, reduction="none")
self.assertEqual(losses, 0.0)
def test_mse_loss(self):
predictions = mx.array([0.5, 0.2, 0.9, 0.0])
targets = mx.array([0.7, 0.1, 0.8, 0.2])
# Test with reduction 'none'
losses_none = nn.losses.mse_loss(predictions, targets, reduction="none")
expected_none = mx.array([0.04, 0.01, 0.01, 0.04])
@@ -62,7 +62,6 @@ class TestNN(mlx_tests.MLXTestCase):
expected_sum = mx.sum(expected_none)
self.assertEqual(losses_sum, expected_sum)
def test_nll_loss(self):
logits = mx.array([[0.0, -float("inf")], [-float("inf"), 0.0]])
targets = mx.array([0, 1])
@@ -82,7 +81,6 @@ class TestNN(mlx_tests.MLXTestCase):
expected_sum = mx.sum(expected_none)
self.assertEqual(losses_sum, expected_sum)
def test_kl_div_loss(self):
p_logits = mx.array([[1.0, 2.0], [0.5, 1.0]])
q_logits = mx.array([[0.8, 1.5], [0.4, 1.2]])