美文网首页
关于gluon.ParameterDict对象打印错误的问题

关于gluon.ParameterDict对象打印错误的问题

作者: chenyihang | 来源:发表于2018-01-17 10:19 被阅读0次

    1.参考资料

    课程地址:
    http://zh.gluon.ai/chapter_gluon-basics/custom-layer.html#%E5%B8%A6%E6%A8%A1%E5%9E%8B%E5%8F%82%E6%95%B0%E7%9A%84%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B1%82

    image.png
    其中在In[7]中报错:
    /home/deeplearning/anaconda3/bin/python /home/deeplearning/PycharmProjects/pyworker/com/xiuhong/mxnet/gression/demo.py
    /home/deeplearning/anaconda3/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py:46: DeprecationWarning: OpenSSL.rand is deprecated - you should use os.urandom instead
    import OpenSSL.SSL
    Traceback (most recent call last):
    File “/home/deeplearning/PycharmProjects/pyworker/com/xiuhong/mxnet/gression/demo.py”, line 11, in 
    print(pd)
    File “/home/deeplearning/anaconda3/lib/python3.6/site-packages/mxnet/gluon/parameter.py”, line 484, in repr
    for v in self.values()]))
    File “/home/deeplearning/anaconda3/lib/python3.6/site-packages/mxnet/gluon/parameter.py”, line 484, in 
    for v in self.values()]))
    File “/home/deeplearning/anaconda3/lib/python3.6/site-packages/mxnet/gluon/parameter.py”, line 120, in repr
    return s.format(**self.dict)
    KeyError: ‘shape’
    
    Process finished with exit code 1
    

    2.解决

    是mxnet1.0的parameter的bug。如果你不想从源码再安装一遍的话,可以在源代码parametr.py里面把报错那行换成pull request里面的那句就行了:
    return s.format(**self.__dict__)换成return s.format(name=self.name, shape=self.shape, dtype=self.dtype)
    参考地址:
    https://discuss.gluon.ai/t/topic/3626/2
    https://github.com/apache/incubator-mxnet/commit/d77d937eaf7e13a30320368d316516bd9da52ca5

    相关文章

      网友评论

          本文标题:关于gluon.ParameterDict对象打印错误的问题

          本文链接:https://www.haomeiwen.com/subject/vzuyoxtx.html