Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Add unit test for bilinear initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
vlado committed Dec 18, 2018
1 parent 653f3e6 commit 5e59c11
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/python/unittest/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,17 @@ def check_rsp_const_init(init, val):
check_rsp_const_init(mx.initializer.Zero(), 0.)
check_rsp_const_init(mx.initializer.One(), 1.)

def test_bilinear_init():
bili = mx.init.Bilinear()
bili_weight = mx.ndarray.empty((1,1,4,4))
bili._init_weight(None, bili_weight)
bili_1d = np.array([[1/4, 3/4, 3/4, 1/4]])
bili_2d = bili_1d * np.transpose(bili_1d)
assert (np.abs(bili_2d - bili_weight.asnumpy()) < 1e-7).all()

if __name__ == '__main__':
test_variable_init()
test_default_init()
test_aux_init()
test_rsp_const_init()
test_bilinear_init()

0 comments on commit 5e59c11

Please sign in to comment.