mxnet
mxnet copied to clipboard
Add convenient method for numerical Ops under Numpy namespace
Description
This PR adds convenient method for numerical Ops (e.g. exp) under Numpy namespace (i.e. numpy extension ops not included).
This modification will significantly mitigate your pain of writing endless F.np in the hybrid_block.
Take sampling from gumbel distribution as an example
# Before
def gumbel_sample(pi):
eps = F.np.random.uniform(F.np.zeros_like(pi))
L = -F.np.log(-F.np.log(eps)) + F.np.log(pi)
# After
def gumbel_sample(pi):
eps = F.np.random.uniform(F.np.zeros_like(pi)) # I wish this line get shortened in the future.
L = -(-eps.log()).log() + pi.log()