MCPcopy Create free account
hub / github.com/ml-explore/mlx / test_identity

Method test_identity

python/tests/test_init.py:46–54  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

44 self.assertTrue(mx.all(result >= low) and mx.all(result <= high))
45
46 def test_identity(self):
47 for dtype in [mx.float32, mx.float16]:
48 initializer = init.identity(dtype)
49 for shape in [(3,), (3, 3), (3, 3, 3)]:
50 result = initializer(mx.zeros((3, 3)))
51 self.assertTrue(mx.array_equal(result, mx.eye(3)))
52 self.assertEqual(result.dtype, dtype)
53 with self.assertRaises(ValueError):
54 result = initializer(mx.zeros((3, 2)))
55
56 def test_glorot_normal(self):
57 for dtype in [mx.float32, mx.float16]:

Callers

nothing calls this directly

Calls 1

initializerFunction · 0.85

Tested by

no test coverage detected