Created
June 1, 2020 08:14
-
-
Save zheyuye/6548d1b587422be8e7dda895d98c3e2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mxnet as mx | |
x = mx.np.random.normal(0,1,(1,1,512)) | |
table = mx.np.random.normal(0,1,(128,30)) | |
extra_table = mx.np.random.normal(0,1,(384,30)) | |
bias = mx.np.random.normal(0,1,(30,)) | |
y = mx.np.concatenate([table, extra_table], axis=0) | |
res1 = mx.np.dot(x,y) + bias | |
a = mx.np.dot(x[:,:,:128], table) | |
b = mx.np.dot(x[:,:,128:], extra_table) | |
res2 = a+b+bias | |
from numpy.testing import assert_allclose | |
assert_allclose(res1.asnumpy(), res2.asnumpy(), 1e-5, 1e-5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment