Search code examples
mxnet

Why does the weight matrix of the mxnet.gluon.nn.Dense object has no shape?


I try to follow this nice MXNet Tutorial. I create an extremely simple neural network (two input unit, no hidden units and one output unit) doing this:

from mxnet import gluon

net = gluon.nn.Dense(1, in_units=2)

After that I try to take a look at the shape of the weight matrix (the same way as it is described in the tutorial):

print(net.weight)

As a result I expect to see this:

Parameter dense4_weight (shape=(1, 2), dtype=None)

However, I see the following error message:

Traceback (most recent call last):
  File "tmp.py", line 5, in <module>
    print(net.weight)
  File "/usr/local/lib/python3.6/site-packages/mxnet/gluon/parameter.py", line 120, in __repr__
    return s.format(**self.__dict__)
KeyError: 'shape'

Am I doing something wrong?


Solution

  • This is a regression that happened here and has since been fixed on master branch here. Expect it to be fixed in the next MXNet release.