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
+24
View File
@@ -0,0 +1,24 @@
import unittest
import numpy as np
from prml import nn
class TestLog(unittest.TestCase):
def test_log(self):
x = nn.Parameter(2.)
y = nn.log(x)
self.assertEqual(y.value, np.log(2))
y.backward()
self.assertEqual(x.grad, 0.5)
x = np.random.rand(4, 6)
p = nn.Parameter(x)
y = nn.log(p)
self.assertTrue((y.value == np.log(x)).all())
y.backward(np.ones((4, 6)))
self.assertTrue((p.grad == 1 / x).all())
if __name__ == '__main__':
unittest.main()