@@ -67,6 +67,10 @@ def test_randn(self):
67
67
self .assertTrue (normal_test (Tensor .randn ))
68
68
self .assertTrue (equal_distribution (Tensor .randn , torch .randn , lambda x : np .random .randn (* x )))
69
69
70
+ def test_normal (self ):
71
+ self .assertTrue (normal_test (Tensor .normal ))
72
+ self .assertTrue (equal_distribution (Tensor .normal , lambda x : torch .nn .init .normal_ (torch .empty (x ), mean = 0 , std = 1 ), lambda x : np .random .normal (loc = 0 , scale = 1 , size = x )))
73
+
70
74
def test_uniform (self ):
71
75
self .assertFalse (normal_test (Tensor .uniform ))
72
76
self .assertTrue (equal_distribution (Tensor .uniform , lambda x : torch .nn .init .uniform_ (torch .empty (x ), a = - 1 , b = 1 ), lambda x : np .random .uniform (low = - 1 , high = 1 , size = x )))
@@ -86,6 +90,13 @@ def test_kaiming_uniform(self):
86
90
for shape in [(128 , 64 , 3 , 3 ), (20 , 24 )]:
87
91
self .assertTrue (equal_distribution (Tensor .kaiming_uniform , lambda x : torch .nn .init .kaiming_uniform_ (torch .empty (x )), shape = shape ))
88
92
93
+ def test_kaiming_normal (self ):
94
+ Tensor .manual_seed (1337 )
95
+ torch .manual_seed (1337 )
96
+ np .random .seed (1337 )
97
+ for shape in [(128 , 64 , 3 , 3 ), (20 , 24 )]:
98
+ self .assertTrue (equal_distribution (Tensor .kaiming_normal , lambda x : torch .nn .init .kaiming_normal_ (torch .empty (x )), shape = shape ))
99
+
89
100
def test_conv2d_init (self ):
90
101
params = (128 , 256 , (3 ,3 ))
91
102
assert equal_distribution (lambda * _ : nn .Conv2d (* params ).weight , lambda _ : torch .nn .Conv2d (* params ).weight .detach ())
0 commit comments