chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:30:25 +08:00
commit f19b2512d7
562 changed files with 38082 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
import unittest
import numpy as np
from prml import nn
class TestMultiply(unittest.TestCase):
def test_multiply(self):
x = nn.Parameter(2)
y = x * 5
self.assertEqual(y.value, 10)
y.backward()
self.assertEqual(x.grad, 5)
x = np.random.rand(5, 4)
y = np.random.rand(4)
yp = nn.Parameter(y)
z = x * yp
self.assertTrue((z.value == x * y).all())
z.backward(np.ones((5, 4)))
self.assertTrue((yp.grad == x.sum(axis=0)).all())
if __name__ == '__main__':
unittest.main()