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

Method test_sigmoid

python/tests/test_ops.py:1071–1081  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1069 self.assertTrue(np.allclose(result, expected))
1070
1071 def test_sigmoid(self):
1072 a = mx.array([0.0, 1.0, -1.0, 5.0, -5.0])
1073 result = mx.sigmoid(a)
1074 expected = 1 / (1 + np.exp(-a, dtype=np.float32))
1075 self.assertTrue(np.allclose(result, expected))
1076
1077 # Low precision
1078 a = mx.array(-8.0).astype(mx.float16)
1079 self.assertNotEqual(mx.sigmoid(a).item(), 0.0)
1080 a = mx.array(8.0).astype(mx.float16)
1081 self.assertNotEqual(mx.sigmoid(a).item(), 1.0)
1082
1083 def test_allclose(self):
1084 a = mx.array(1.0)

Callers

nothing calls this directly

Calls 2

itemMethod · 0.80
arrayMethod · 0.60

Tested by

no test coverage detected