Hi, everyone
I am new to Python, and when reading the deep learning book, I met some problem.
from mxnet import nd
For the above code, why we can short ndarray for nd? Is this pre-defined by the Mxnet library? Or it is defined somewhere in our own code?
Second question is, before writing the above line, do we need to write import mxnet
first?
Thanks!
sad
2
First: it’s because in the __init__.py
of the top level mxnet package, the ndarray
package is imported as nd. Take a look at the source code here:
https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/init.py#L33
Second: you do not need to do import mxnet
first. It will work if you import nd
directly as long as you have from mxnet
.
1 Like