Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit ad2e989

Browse files
author
Ehsan Totoni
committed
test linear regression
1 parent 81cac48 commit ad2e989

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

hpat/tests/test_ml.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,24 @@ def test_impl(N, D):
4848
#self.assertEqual(count_array_OneDs(), 3)
4949
#self.assertEqual(count_parfor_OneDs(), 3)
5050

51+
def test_linear_regression(self):
52+
def test_impl(N, D):
53+
p = 2
54+
iterations = 3
55+
X = np.ones((N, D)) + .5
56+
Y = np.ones((N, p))
57+
alphaN = 0.01 / N
58+
w = np.zeros((D, p))
59+
for i in range(iterations):
60+
w -= alphaN * np.dot(X.T, np.dot(X, w) - Y)
61+
return w
62+
63+
hpat_func = hpat.jit(test_impl)
64+
n = 11
65+
d = 4
66+
np.testing.assert_allclose(hpat_func(n, d), test_impl(n, d))
67+
self.assertEqual(count_array_OneDs(), 5)
68+
self.assertEqual(count_parfor_OneDs(), 3)
69+
5170
if __name__ == "__main__":
5271
unittest.main()

0 commit comments

Comments
 (0)